// test test
#include <iostream>

using namespace std;

bool used[101], us[101];
string s[101];
int n, k, a[101], c = false;

int main()
{
    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        cin >> k;
        for (int j = 1; j <= k; j++)
        {
            cin >> a[j];
            if (a[j] < a[j - 1])
                c = true;
        }
        if (c)
            s[i - 1] = "NO";
        else if (used[a[k]])
        {
            for (int l = 0; l <= n; l++)
            {
                if (us[l] != 0)
                s[l] = "NO";
            }
            s[i - 1] = "NO";
        }
        else
        {
            s[i - 1] = "YES";
            used[a[k]] = 1;
            us[i - 1] = 1;
        }
        c = false;
    }
    for (int i = 0; i < n; i++)
        cout << s[i] << endl;

    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int used[1001];
int a[101][101];
int main()
{
    int n,maxx=0;
    cin>>n;
    int m;

    for(int i=0;i<n;i++)
    {
        cin>>m;
        if(m>maxx)
            maxx=m;
        for(int j=0;j<m;j++ )
        {
           cin>>a[i][j];
        }
    }

    for(int i=0;i<n;i++)
    {
        int p=0;
        for(int h=0;h<maxx;h++)
        {
            for(int j=0;j<n;j++)
            {
                if(j!=i)
                {
                    if(a[i][h]==0)
                        {p=1;break;}
                    if(a[i][h]==a[j][h] || used[a[i][h]]==1)
                    {p=-1;cout<<"NO"<<endl;break;}

                }
                if(p==-1 || p==1)
                    break;
            }
            used[a[i][h]]=1;
            if(p==-1 || p==1)
                break;
        }
        for(int h=0;h<maxx;h++)
        used[a[i][h]]=1;
        if(p==1 || p==0)
        cout<<"YES"<<endl;
    }

    return 0;
}


// test test not mine
#include <iostream>

using namespace std;

string s[101];
int a[101], l[101], k, n, c = 0, d = 0, used[101], f;

int main()
{

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> a[j];
            if (a[j] < a[j - 1])
                d = 1;
        }
        if (d == 1) s[i] = "NO";
        else
        l[i] = a[k - 1];
        d = 0;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (l[i] == l[j] && i != j)
                s[i] = "NO";
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (s[i] != "NO") s[i] = "YES";
        cout << s[i] << endl;
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <math.h>
#define pb push_back
#define mp make_pair

using namespace std;

int fin[150];
vector<vector<int> > vec(105);
string ans[140];

int main()
{
    int n, m;
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> m;
        for(int j = 0; j < m; j++) cin >> a, vec[i].pb(a);
        sort(vec[i].begin(), vec[i].end());
        vec[i].pb(0);
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)  vec[j][vec[j].size()-1]=0;
        for(int j = 0; j < vec[i].size()-1; j++)
        {
            int q = 0;
            for(int k = 0; k < n; k++)
            {
                if(k == i) continue;
                if(vec[i][j] == vec[k][vec[k][vec[k].size()-1]])
                {
                    vec[k][vec[k].size()-1]++;
                    if(vec[k][vec[k].size()-1] == vec[k].size()-1) {ans[i] += "NO"; q = 1; break;}
                }
            }
            if(q == 1) break;
            if(j == vec[i].size()-2 && !q)  ans[i] += "YES";
        }
    }
    for(int i = 0; i < n; i++) cout << ans[i] <<endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <map>
#include <set>
using namespace std;
/***************************************/
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int ,int> MII;
typedef map<string,int> MSI;
typedef pair<int,int> PII;
typedef vector<PII> VII;
typedef vector<VI > VVI;
/***************************************/
#define clr(a,b) memset(a,b,sizeof(a))
#define ll long long
#define int64 __int64
#define LL(x) ((x)<<1)
#define RR(x) ((x)<<1|1)
#define MP(a,b) make_pair(a,b)
#define RI(x) scanf("%d",&x)
#define RII(x,y) scanf("%d%d",&x,&y)
#define RD(x) scanf("%lf",&x)
#define RDD(x,y) scanf("%lf%lf",&x,&y)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d",x)
#define PS(x) printf("%s",x)
#define PN()  printf("\n")
#define REP(i,a,b)  for(int i=(a);i<(b);i++)
#define REPU(i,a,b) for(int i=(a);i<=(b);i++)
#define REPD(i,a,b) for(int i=(a);i>=(b);i--)
#define REPC(i,a,c) for(int i=(a);(c);i++)
/***************************************/
const int INF = 0x7f7f7f7f;
const double eps = 1e-8;
const double PIE=acos(-1.0);
const int dx[]= {0,-1,0,1};
const int dy[]= {1,0,-1,0};
const int fx[]= {-1,-1,-1,0,0,1,1,1};
const int fy[]= {-1,0,1,-1,1,-1,0,1};
/***************************************/
void openfile()
{
	freopen("data.in","rb",stdin);
	freopen("data.out","wb",stdout);
}
/***************************************/

int a[110][110];
int main()
{
	int n,m,x;
	RI(n);
	clr(a,0);
	REP(i,0,n)
	{
		RI(m);
		REP(j,0,m)
		{
			RI(x);
			a[i][x]=1;
		}
	}
	int flag;
	REP(i,0,n)
	{
        flag=1;
		REP(j,0,n)
		{
			if(i==j)	continue;
			flag=0;
			REPU(k,1,100)
				if(a[j][k]&&!a[i][k])
				{
					flag=1;
					break;
				}
			if(flag==0)
				break;
		}
		if(flag)
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}


#include <iostream>
#include<stdio.h>
#include<string.h>
int main()
{
    int n,m,t;
    while(scanf("%d",&n)!=EOF)
    {
        int a[150][150]= {{0}};
        for(int i=0; i<n; i++)
        {
            scanf("%d",&m);
            for(int j=0; j<m; j++)
            {
                scanf("%d",&t);
                a[i][t]=1;
            }
        }
        int flag;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(i==j)
                    continue;
                flag=0;
                for(int r=1; r<=100; r++)
                    if(a[j][r]&&!a[i][r])
                    {
                        flag=1;
                        break;
                    }
                if(flag==0)
                    break;
            }
            if(flag)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
struct node
{
    int a[111];
    int b;
} m[111];
int main()
{
    int n,i,j;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0; i<n; i++)
        {
            scanf("%d",&m[i].b);
            for(j=0; j<m[i].b; j++)
            {
                scanf("%d",&m[i].a[j]);
            }
            sort(m[i].a,m[i].a+m[i].b);
        }
        int vis[111];
        int t;
        memset(vis,0,sizeof(vis));
        for(i=0; i<n; i++)
        {

            for(j=0; j<n; j++)
            {
                t=0;
                if(i==j)continue;
                if((vis[j]==1||vis[i]==1)&&m[i].b!=m[j].b)continue;
                if(m[i].b<m[j].b)continue;
                for(int k=0; k<m[j].b; k++)
                {
                    if(m[i].a[k]!=m[j].a[k])
                    {
                        t=1;
                        break;
                    }
                }
                if(t==0)
                {
                    vis[i]=1;
                    break;
                }
            }
        }
        for(i=0; i<n; i++)
        {
            if(vis[i])printf("NO\n");
            else printf("YES\n");
        }
    }
    return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
struct node
{
    int a[111];
    int b;
} m[111];
int main()
{
    int n,i,j;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0; i<n; i++)
        {
            scanf("%d",&m[i].b);
            for(j=0; j<m[i].b; j++)
            {
                scanf("%d",&m[i].a[j]);
            }
            sort(m[i].a,m[i].a+m[i].b);
        }
        int vis[111];
        int t;
        memset(vis,0,sizeof(vis));
        for(i=0; i<n; i++)
        {
            for(j=0; j<n; j++)
            {
                t=0;
                if(i==j)continue;
                if(m[i].b<m[j].b)continue;
                int x=0;
                for(int k=0; k<m[j].b; k++)
                {
                    int k2;
                    for(k2=0;k2<m[i].b;k2++)
                    {
                        if(m[j].a[k]==m[i].a[k2])
                        {
                            break;
                        }
                    }
                    if(k2==m[i].b)
                    {
                        t=1;break;
                    }
                }
                if(t==0)
                {
                    vis[i]=1;
                    break;
                }
            }
        }
        for(i=0; i<n; i++)
        {
            if(vis[i]==1)printf("NO\n");
            else printf("YES\n");
        }
    }
    return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
struct node
{
    int a[111];
    int b;
} m[111];
int main()
{
    int n,i,j;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0; i<n; i++)
        {
            scanf("%d",&m[i].b);
            for(j=0; j<m[i].b; j++)
            {
                scanf("%d",&m[i].a[j]);
            }
            //sort(m[i].a,m[i].a+m[i].b);
        }
        int vis[111];
        int t;
        memset(vis,0,sizeof(vis));
        for(i=0; i<n; i++)
        {
            for(j=0; j<n; j++)
            {
                t=0;
                if(i==j)continue;
                if(m[i].b<m[j].b)continue;
                int x=0;
                for(int k=0; k<m[j].b; k++)
                {
                    int k2;
                    for(k2=0;k2<m[i].b;k2++)
                    {
                        if(m[j].a[k]==m[i].a[k2])
                        {
                            break;
                        }
                    }
                    if(k2==m[i].b)
                    {
                        t=1;break;
                    }
                }
                if(t==0)
                {
                    vis[i]=1;
                    break;
                }
            }
        }
        for(i=0; i<n; i++)
        {
            if(vis[i]==1)printf("NO\n");
            else printf("YES\n");
        }
    }
    return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
struct node
{
    int a[111];
    int b;
} m[111];
int main()
{
    int n,i,j;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0; i<n; i++)
        {
            scanf("%d",&m[i].b);
            for(j=0; j<m[i].b; j++)
            {
                scanf("%d",&m[i].a[j]);
            }
        }
        int vis[111];
        int t;
        memset(vis,0,sizeof(vis));
        for(i=0; i<n; i++)
        {
            for(j=0; j<n; j++)
            {
                t=0;
                if(i==j)continue;
                if(m[i].b<m[j].b)continue;
                if(vis[j]==1&&(m[i].b!=m[j].b))continue;
                int x=0;
                for(int k=0; k<m[j].b; k++)
                {
                    int k2;
                    for(k2=0;k2<m[i].b;k2++)
                    {
                        if(m[j].a[k]==m[i].a[k2])
                        {
                            break;
                        }
                    }
                    if(k2==m[i].b)
                    {
                        t=1;break;
                    }
                }
                if(t==0)
                {
                    vis[i]=1;
                    break;
                }
            }
        }
        for(i=0; i<n; i++)
        {
            if(vis[i]==1)printf("NO\n");
            else printf("YES\n");
        }
    }
    return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
struct node
{
    int a[111];
    int b;
} m[111];
int main()
{
    int n,i,j;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0; i<n; i++)
        {
            scanf("%d",&m[i].b);
            for(j=0; j<m[i].b; j++)
            {
                scanf("%d",&m[i].a[j]);
            }
            sort(m[i].a,m[i].a+m[i].b);
        }
        int vis[111];
        int t;
        memset(vis,0,sizeof(vis));
        for(i=0; i<n; i++)
        {

            for(j=0; j<n; j++)
            {
                t=0;
                if(i==j)continue;
                if(m[i].b<m[j].b)continue;
                for(int k=0; k<m[j].b; k++)
                {
                    if(m[i].a[k]!=m[j].a[k])
                    {
                        t=1;
                        break;
                    }
                }
                if(t==0)
                {
                    vis[i]=1;
                    break;
                }
            }
        }
        for(i=0; i<n; i++)
        {
            if(vis[i])printf("NO\n");
            else printf("YES\n");
        }
    }
    return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
struct node
{
    int a[111];
    int b;
} m[111];
int main()
{
    int n,i,j;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0; i<n; i++)
        {
            scanf("%d",&m[i].b);
            for(j=0; j<m[i].b; j++)
            {
                scanf("%d",&m[i].a[j]);
            }
        }
        int vis[111];
        int t;
        memset(vis,0,sizeof(vis));
        for(i=0; i<n; i++)
        {
            for(j=0; j<n; j++)
            {
                t=0;
                if(i==j)continue;
                if(m[i].b<m[j].b)continue;
               // if(vis[j]==1&&(m[i].b!=m[j].b))continue;
                int x=0;
                for(int k=0; k<m[j].b; k++)
                {
                    int k2;
                    for(k2=0;k2<m[i].b;k2++)
                    {
                        if(m[j].a[k]==m[i].a[k2])
                        {
                            break;
                        }
                    }
                    if(k2==m[i].b)
                    {
                        t=1;break;
                    }
                }
                if(t==0)
                {
                    vis[i]=1;
                    break;
                }
            }
        }
        for(i=0; i<n; i++)
        {
            if(vis[i]==1)printf("NO\n");
            else printf("YES\n");
        }
    }
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

const int MAX=105;
int n,m,v;
vector<int> gr[MAX];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&m);
		for(int j=0;j<m;j++){
			scanf("%d",&v);
			gr[i].push_back(v);
		}
		sort(gr[i].begin(),gr[i].end());
	}
	for(int i=0;i<n;i++){
		bool flag=true;
		int nc=gr[i].size();
		for(int j=0;j<n;j++){
			if(i==j) continue;
			int t=0,k=0;
			for(;k<gr[j].size();k++){
				if(gr[i][t]==gr[j][k]&&t<nc) t++;
				else break;
			}
			if(t<=nc&&k==gr[j].size()){
				flag=false;
				break;
			}
		}
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAX=105;
int n,m[MAX],pai[MAX],point[MAX*MAX],sum[MAX],Max,a;

int main(){
	scanf("%d",&n);
	memset(pai,0,sizeof(pai));
	memset(point,0,sizeof(point));
	memset(sum,0,sizeof(sum));
	Max=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&m[i]);
		pai[m[i]]++;
		Max=max(Max,m[i]);
		for(int j=1;j<=m[i];j++){
			scanf("%d",&a);
			sum[i]+=a;
		}
		point[sum[i]]++;
	}
	if(n==1){
		printf("YES\n");
		return 0;
	}
	if(pai[Max]!=1) Max=-1;
	for(int i=1;i<=n;i++){
		if(pai[m[i]]!=1){
			if(point[sum[i]]==1) printf("YES\n");
			else printf("NO\n");
		}
		else{
			if(m[i]!=Max) printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int INF=0x3f3f3f3f;
const int MAX=105;
int n,m[MAX],pai[MAX],point[MAX*MAX],sum[MAX],Max,a;

int main(){
	scanf("%d",&n);
	memset(pai,0,sizeof(pai));
	memset(point,0,sizeof(point));
	memset(sum,0,sizeof(sum));
	Max=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&m[i]);
		pai[m[i]]++;
		Max=max(Max,m[i]);
		for(int j=1;j<=m[i];j++){
			scanf("%d",&a);
			sum[i]+=a;
		}
		point[sum[i]]++;
	}
	int Min=INF;
	for(int i=1;i<=n;i++){
		if(pai[m[i]]!=1&&point[sum[i]]!=1) Min=min(Min,m[i]);
	}
	if(n==1){
		printf("YES\n");
		return 0;
	}
	if(pai[Max]!=1) Max=-1;
	for(int i=1;i<=n;i++){
		if(m[i]>=Min) printf("NO\n");
		else{
		if(pai[m[i]]!=1){
			if(point[sum[i]]==1) printf("YES\n");
			else printf("NO\n");
		}
		else{
			if(m[i]!=Max) printf("YES\n");
			else printf("NO\n");
		}
		}
	}
	return 0;
}


#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;

const int MAX=105;
int n,m[MAX],v;
set<int> se[MAX];
set<int>::iterator it;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&m[i]);
		for(int j=0;j<m[i];j++){
			scanf("%d",&v);
			se[i].insert(v);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=true;
		for(int j=0;j<n;j++){
			if(i==j) continue;
			bool ok=false;
			for(it=se[j].begin();it!=se[j].end();it++){
				if(se[i].find(*it)==se[i].end()){
					ok=true;
					break;
				}
			}
			if(ok==false){
				flag=false;
				break;
			}
		}
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAX=105;
int n,m[MAX],pai[MAX],point[MAX*MAX],sum[MAX],Max,a;

int main(){
	scanf("%d",&n);
	memset(pai,0,sizeof(pai));
	memset(point,0,sizeof(point));
	memset(sum,0,sizeof(sum));
	Max=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&m[i]);
		pai[m[i]]++;
		Max=max(Max,m[i]);
		for(int j=1;j<=m[i];j++){
			scanf("%d",&a);
			sum[i]+=a;
		}
		point[sum[i]]++;
	}
	if(n==1){
		printf("YES\n");
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(pai[m[i]]==1&&point[sum[i]]==1&&m[i]!=Max) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAX=105;
int n,m[MAX],pai[MAX],point[MAX*MAX],sum[MAX],Max,a;

int main(){
	scanf("%d",&n);
	memset(pai,0,sizeof(pai));
	memset(point,0,sizeof(point));
	memset(sum,0,sizeof(sum));
	Max=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&m[i]);
		pai[m[i]]++;
		Max=max(Max,m[i]);
		for(int j=1;j<=m[i];j++){
			scanf("%d",&a);
			sum[i]+=a;
		}
		point[sum[i]]++;
	}
	for(int i=1;i<=n;i++){
		if(pai[m[i]]==1&&point[sum[i]]==1&&m[i]!=Max) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <math.h>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <string>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
using namespace std;
#define fname ""
#define ull unsigned long long
#define ll long long
#define INF 1000*1000*1000

bool was[10001], ok;
int a[101][101], n,m,i,j,x, k, b[101];

int main () {
  #ifndef ONLINE_JUDGE
    freopen ("a.in", "r", stdin);
    freopen ("a.out", "w", stdout);
    #endif
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> b[i];
        for (j = 1; j <= b[i]; j++)
            cin >> a[i][j];
        sort(a[i] + 1, a[i] + b[i] + 1);
    }
    for (i = 1; i <= n; i++) {
        ok = true;
        for (j = 1; j <= n; j++) {
            if (j != i)
            for (k = 1; k <= b[i]; k++) {
                if (k == b[j] && a[i][k] == a[j][k]) {
                    ok = false;
                    goto w;
                }
                if (a[i][k] != a[j][k])
                    break;
                }
        }
            w:;
            if (ok)
                cout << "YES";
            else
                cout << "NO";
            cout << endl;
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <math.h>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <string>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
using namespace std;
#define fname ""
#define ull unsigned long long
#define ll long long
#define INF 1000*1000*1000

int n,i,j,k,m[101],a[101][105],b[101][105],x,c[101][106];
bool was, was1;

int main() {
#ifndef ONLINE_JUmGE
freopen ("a.in", "r", stdin);
freopen ("a.out", "w", stdout);
#endif
cin >> n;
for (i = 1; i <= n; i++)
{
cin >> m[i];
for (j = 1; j <= m[i]; j++)
{
cin >> a[i][j];
c[i][a[i][j]] = 1;
}
a[i][101] = m[i];
}
for (i = 1; i <= n; i++)
{
was = was1 = false;
for (j = 1; j <= n; j++)
{
for (k = 1; k <= m[j]; k++)
b[j][k] = a[i][k];
b[j][101] = m[j];
}
for (j = 1; j <= m[i]; j++)
{
for (k = 1; k <= n; k++)
if (c[k][b[i][j]] == 1)
{
b[k][101]--;
if (b[k][101] == 0 && k != i)
{
was = true;
}
if (b[k][101] == 0 && k == i)
{
was1 = true;
}
}
if (was1 && !was) { cout << "YES\n"; break; }
if (was) { cout << "NO\n"; break; }
}
}
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <math.h>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <string>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
using namespace std;
#define fname ""
#define ull unsigned long long
#define ll long long
#define INF 1000*1000*1000

bool was[10001], ok,ok1;
int a[101][101], n,m,i,j,x, k, b[101];
int t;
int main () {
  #ifndef ONLINE_JUDGE
    freopen ("a.in", "r", stdin);
    freopen ("a.out", "w", stdout);
    #endif
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> b[i];
        for (j = 1; j <= b[i]; j++)
            cin >> a[i][j];
        sort(a[i] + 1, a[i] + b[i] + 1);
        was[i] = true;
    }
    for (i = 1; i <= n; i++) {
        ok = true;
        for (j = 1; j <= n; j++) {
            if (j != i){
            t = 1;
            ok1 = false;
            for (k = 1; k <= b[j]; k++) {
                if (a[i][t] > a[j][k] && !ok1)
                   continue;
                if (a[i][t] < a[j][k] && !ok1) {
                while (a[i][t] < a[j][k]) {
                t++;
                }
                }
                ok1=true;
                if ((k == b[i] || k == b[j] || t==b[i] || t==b[j])&&b[i]>=b[j]&& a[i][t] == a[j][k]) {
                    ok = false;
                    goto w;
                }
                if (k == b[i] || k == b[j] || t == b[i] || t == b[j])
                   break;
                if (a[i][t] != a[j][k])
                    break;

                t++;}
            }
        }
            w:;
            if (ok)
                cout << "YES";
            else
                cout << "NO";
            cout << endl;
    }
    return 0;
}


def list_input():
    return list(map(int,input().split()))
def map_input():
    return map(int,input().split())
def map_string():
    return input().split()

n,p,q,r = map_input()
a = [p,q,r]
b = list_input()
ans = 0
for i in a:
  cur = -100000000000000000000000
  for j in b:
    cur = max(cur,i*j)
  ans += cur
print(ans)


n,p,q,r=[int(x) for x in input().split()]
a=list(map(int,input().split()))
ap=[a[0]*p]*n

for i in range(1,n):
    ap[i]=max(ap[i-1],a[i]*p)

aq=[a[0]*q+ap[0]]*n

for i in range(1,n):
    aq[i]=max(aq[i-1],a[i]*q+ap[i])

ar=[a[0]*r+aq[0]]*n

for i in range(1,n):
    ar[i]=max(ar[i-1],a[i]*r+aq[i])
print(ar[n-1])


s = input()
inf = 1e30
s = [int(x) for x in s.split()]
n = s[0]
p = s[1]
q = s[2]
r = s[3]
a = input()
a = [int(x) for x in a.split()]
dp = []
for i in range(n+1):
    dp.append(0)
dp[0] = -inf
i = 1
while i<=n :
    now = p * a[i-1]
    dp[i] = max(dp[i-1],now)
    i = i+1
i=1
while i<=n :
    now = q * a[i-1]
    dp[i] = max(dp[i-1],dp[i] + now)
    i = i+1
i = 1
ans = -inf
while i<=n:
    now = r * a[i-1]
    dp[i] = max(dp[i-1],dp[i] + now)
    ans = max(ans,dp[i])
    i = i+1
print (ans)


s = input()
inf = 1e18
s = [int(x) for x in s.split()]
n = s[0]
p = s[1]
q = s[2]
r = s[3]
a = input()
a = [int(x) for x in a.split()]
dp = []
for i in range(n+1):
    dp.append(0)
dp[0] = -inf
i = 1
while i<=n :
    now = p * a[i-1]
    dp[i] = max(dp[i-1],now)
    i = i+1
i=1
while i<=n :
    now = q * a[i-1]
    dp[i] = max(dp[i-1],dp[i] + now)
    i = i+1
i = 1
ans = -inf
while i<=n:
    now = r * a[i-1]
    dp[i] = max(dp[i-1],dp[i] + now)
    ans = max(ans,dp[i])
    i = i+1
print (ans)


s = input()
s = [int(x) for x in s.split()]
n = s[0]
a = input()
a = [int(x) for x in a.split()]
a.sort()
ans = 0
for i in range(3):
    if s[i+1]>=0:
        ans += s[i+1]*a[len(a)-1]
    elif s[i+1]<0:
        ans += s[i+1]*a[0];
print (ans);


n, p, q, r = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
crmx, crmn = [a[n - 1]] * n, [a[n - 1]] * n

for i in range(n - 2, -1, -1):
    crmx[i] = max(crmx[i + 1], a[i])
    crmn[i] = min(crmn[i + 1], a[i])

ans = 0 - 10 ** 21

mn, mx = a[0], a[0]

for i in range(n):
    cans = q * a[i]
    mx = max(mx, a[i])
    mn = min(mn, a[i])
    cans += max(mx * p, mn * p)
    cans += max(crmx[i] * r, crmn[i] * r)
    ans = max(ans, cans)

print(ans)


n, p, q, r = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
mx = max(a)
mn = min(a)

ans = 0
if p >= 0:
    ans += p * mx
else:
    ans += p * mn
if q >= 0:
    ans += q * mx
else:
    ans += q * mn
if r >= 0:
    ans += r * mx
else:
    ans += r * mn

print(ans)


import math
n,p,q,r = map(int,input().split())
aa = [int(i) for i in input().split()]
pp,qq,rr = -math.inf,-math.inf,-math.inf
for i in aa:
    pp = max(pp,p*i)
    qq = max(qq,pp+q*i)
    rr = max(rr,qq+r*i)
print(rr)


n,p,q,r = map(int,input().split())
aa = [int(i) for i in input().split()]
pp,qq,rr = -2*pow(10,9),-2*pow(10,9),-2*pow(10,9)
for i in aa:
    pp = max(pp,p*i)
    qq = max(qq,pp+q*i)
    rr = max(rr,qq+r*i)
print(rr)


I = lambda: map(int, input().rstrip().split())
n, p, q, r = I()
a = list(sorted(I()))
positives = []
negatives = []
zeros = []
for x in a:
    if x < 0:
        negatives.append(x)
    elif x > 0:
        positives.append(x)
    else:
        zeros.append(x)
ans = 0
for x in [p, q, r]:
    if x >= 0:
        if len(positives) > 0:
            ans += x * positives[-1]
        elif len(zeros) > 0:
            ans += 0
        else:
            ans += x * negatives[-1]
    else:
        if len(negatives) > 0:
            ans += x * negatives[0]
        elif len(zeros) > 0:
            ans += 0
        else:
            ans += x * positives[0]
print(ans)


I = lambda: map(int, input().rstrip().split())
n, p, q, r = I()
a = list(I())
pp = -1e20
pq = -1e20
pr = -1e20
for x in a:
    pp = max(pp, p * x)
    pq = max(pq, pp + q * x)
    pr = max(pr, pq + r * x)
print(pr)


n,p,q,r=map(int,input().split())
arr=[int(i) for i in input().split()]
# leftmax=[arr[0]]
# for i in range(1,len(arr)):
#   leftmax.append(max(leftmax[-1],arr[i]))
# print(leftmax)
# rightmax=[arr[-1]]
# for i in range(len(arr)-2,-1,-1):
#   rightmax.append(max(rightmax[-1],arr[i]))
# rightmax.reverse()
# print(rightmax)
# ans=float('-inf')
# for i in range(1,len(arr)-1):
#   temp=(p*leftmax[i-1])+(q*arr[i])+(r*rightmax[i+1])
#   print(temp)
#   ans=max(ans,temp)
parr=[arr[0]*p]
for i in range(1,len(arr)):
  val=max(arr[i]*p,parr[i-1])
  parr.append(val)
qarr=[arr[0]*q+(p*arr[0])]
for i in range(1,len(arr)):
  val=max(qarr[i-1],(arr[i]*q)+(parr[i]))
  qarr.append(val)
rarr=[(arr[0]*q)+(p*arr[0])+(r*arr[0])]
for i in range(1,len(arr)):
  val=max(rarr[i-1],r*arr[i]+qarr[i])
  rarr.append(val)
print(rarr[-1])


n,p,q,r = [int(i) for i in input().split(" ")]
a = list(input())
b = []
i = 0
while i < len(a):
    if a[i] == ' ':
        i += 1
    if a[i] == '-':
        b.append(int(a[i]+a[i+1]))
        i += 2
    else:
        b.append(int(a[i]))
        i += 1

print(b)
#num = [p,q,r]
l = []
sum = 0
x = len(b)
for i in range(x):
    for j in range(i,x):
        for k in range(j,x):
            sum = max(sum, p*b[i] + q*b[j] + r*b[k])

print(sum)

# def indiceb(b):
#     for i in range(len(b)):
#         if b[i] == max(b):
#             return i
#
#
# def indices(b):
#     for i in range(len(b)):
#         if b[i] == min(b):
#             return i
#
# if p > 0:
#     sum += max(b) * p
# if p < 0:
#     sum += min(b) * p
#
# if q > 0:
#     sum += max(b[indices(b):]) * q
# if q < 0:
#     sum += min(b) * q
#
# #
# for ii in range(3):
#     if num[ii] >= 0:
#         sum += max(b)*num[ii]
#     if num[ii] < 0:
#         sum += min(b)*num[ii]


# -------------INPUT---------------------------
n, p, q, r = [int(i) for i in input().split(" ")]
a = input()

b = a.split()

for i in range(n):
    b[i] = int(b[i])

# ---------------------------------------------

dp = [p * b[0]]
for i in range(1, n):
    dp.append(max(dp[i - 1], p * b[i]))
# print(dp)

dq = [dp[0] + q * b[0]]
for i in range(1, n):
    dq.append(max(dq[i - 1], dp[i] + q * b[i]))
# print(dq)

dr = [dq[0] + r * b[0]]
for i in range(1, n):
    dr.append(max(dr[i - 1], dq[i] + r * b[i]))

print(dr[-1])
#  i = 0
# while i < len(a):
#     if a[i] == ' ':
#         i += 1
#     if a[i] == '-':
#         b.append(int(a[i]+a[i+1]))
#         i += 2
#     else:
#         b.append(int(a[i]))
#         i += 1
# print(b)
# num = [p,q,r]
# l = []
# sum = p * b[0] + q * b[0] + r * b[0]
# x = len(b)
# for i in range(x):
#     for j in range(i, x):
#         for k in range(j, x):
#             # print((i,j,k))
#             sum = max(sum, p * b[i] + q * b[j] + r * b[k])
#
# # print(sum)
#
#
# # def indiceb(b):
# #     for i in range(len(b)):
# #         if b[i] == max(b):
#             return i
#
#
# def indices(b):
#     for i in range(len(b)):
#         if b[i] == min(b):
#             return i
#
# if p > 0:
#     sum += max(b) * p
# if p < 0:
#     sum += min(b) * p
#
# if q > 0:
#     sum += max(b[indices(b):]) * q
# if q < 0:
#     sum += min(b) * q
#
# #
# for ii in range(3):
#     if num[ii] >= 0:
#         sum += max(b)*num[ii]
#     if num[ii] < 0:
#         sum += min(b)*num[ii]


n,p,q,r = [int(i) for i in input().split(" ")]
a = input()

b = a.split()

for i in range(len(b)):
    b[i] = int(b[i])
#print(b)

# i = 0
# while i < len(a):
#     if a[i] == ' ':
#         i += 1
#     if a[i] == '-':
#         b.append(int(a[i]+a[i+1]))
#         i += 2
#     else:
#         b.append(int(a[i]))
#         i += 1
# print(b)
#num = [p,q,r]
l = []
sum = p*b[0] + q*b[0] + r*b[0]
x = len(b)
for i in range(x):
    for j in range(i,x):
        for k in range(j,x):
            #print((i,j,k))
            sum = max(sum, p*b[i] + q*b[j] + r*b[k])

print(sum)

# def indiceb(b):
#     for i in range(len(b)):
#         if b[i] == max(b):
#             return i
#
#
# def indices(b):
#     for i in range(len(b)):
#         if b[i] == min(b):
#             return i
#
# if p > 0:
#     sum += max(b) * p
# if p < 0:
#     sum += min(b) * p
#
# if q > 0:
#     sum += max(b[indices(b):]) * q
# if q < 0:
#     sum += min(b) * q
#
# #
# for ii in range(3):
#     if num[ii] >= 0:
#         sum += max(b)*num[ii]
#     if num[ii] < 0:
#         sum += min(b)*num[ii]


# -------------INPUT---------------------------
n, p, q, r = [int(i) for i in input().split(" ")]
a = input()

b = a.split()

for i in range(n):
    b[i] = int(b[i])

# ---------------------------------------------

dp = []
for i in range(n):
    if p >= 0:
        dp.append(max(b[:i + 1]) * p)
    if p < 0:
        dp.append(min(b[:i + 1]) * p)

dq = []
for i in range(n):
    if q >= 0:
        dq.append(dp[i] + max(b[:i + 1]) * q)
    if q < 0:
        dp.append(dp[i] + min(b[:i + 1]) * q)

dr = []
for i in range(n):
    if r >= 0:
        dr.append(dq[i] + max(b[:i + 1]) * r)
    if r < 0:
        dr.append(dq[i] + min(b[:i + 1]) * r)
print(max(dr))
#  i = 0
# while i < len(a):
#     if a[i] == ' ':
#         i += 1
#     if a[i] == '-':
#         b.append(int(a[i]+a[i+1]))
#         i += 2
#     else:
#         b.append(int(a[i]))
#         i += 1
# print(b)
# num = [p,q,r]
# l = []
# sum = p * b[0] + q * b[0] + r * b[0]
# x = len(b)
# for i in range(x):
#     for j in range(i, x):
#         for k in range(j, x):
#             # print((i,j,k))
#             sum = max(sum, p * b[i] + q * b[j] + r * b[k])
#
# # print(sum)
#
#
# # def indiceb(b):
# #     for i in range(len(b)):
# #         if b[i] == max(b):
#             return i
#
#
# def indices(b):
#     for i in range(len(b)):
#         if b[i] == min(b):
#             return i
#
# if p > 0:
#     sum += max(b) * p
# if p < 0:
#     sum += min(b) * p
#
# if q > 0:
#     sum += max(b[indices(b):]) * q
# if q < 0:
#     sum += min(b) * q
#
# #
# for ii in range(3):
#     if num[ii] >= 0:
#         sum += max(b)*num[ii]
#     if num[ii] < 0:
#         sum += min(b)*num[ii]


n,p,q,r = [int(i) for i in input().split(" ")]
a = list(input())
b = []
i = 0
while i < len(a):
    if a[i] == ' ':
        i += 1
    if a[i] == '-':
        b.append(int(a[i]+a[i+1]))
        i += 2
    else:
        b.append(int(a[i]))
        i += 1

#num = [p,q,r]
l = []
sum = 0
x = len(b)
for i in range(x):
    for j in range(i,x):
        for k in range(j,x):
            sum = max(sum, p*b[i] + q*b[j] + r*b[k])

print(sum)

# def indiceb(b):
#     for i in range(len(b)):
#         if b[i] == max(b):
#             return i
#
#
# def indices(b):
#     for i in range(len(b)):
#         if b[i] == min(b):
#             return i
#
# if p > 0:
#     sum += max(b) * p
# if p < 0:
#     sum += min(b) * p
#
# if q > 0:
#     sum += max(b[indices(b):]) * q
# if q < 0:
#     sum += min(b) * q
#
# #
# for ii in range(3):
#     if num[ii] >= 0:
#         sum += max(b)*num[ii]
#     if num[ii] < 0:
#         sum += min(b)*num[ii]


n,p,q,r = [int(i) for i in input().split(" ")]
a = list(input())
b = []
i = 0
while i < len(a):
    if a[i] == ' ':
        i += 1
    if a[i] == '-':
        b.append(int(a[i]+a[i+1]))
        i += 2
    else:
        b.append(int(a[i]))
        i += 1

#num = [p,q,r]
l = []
sum = p*b[0] + q*b[0] + r*b[0]
x = len(b)
for i in range(x):
    for j in range(i,x):
        for k in range(j,x):
            #print((i,j,k))
            sum = max(sum, p*b[i] + q*b[j] + r*b[k])

print(sum)

# def indiceb(b):
#     for i in range(len(b)):
#         if b[i] == max(b):
#             return i
#
#
# def indices(b):
#     for i in range(len(b)):
#         if b[i] == min(b):
#             return i
#
# if p > 0:
#     sum += max(b) * p
# if p < 0:
#     sum += min(b) * p
#
# if q > 0:
#     sum += max(b[indices(b):]) * q
# if q < 0:
#     sum += min(b) * q
#
# #
# for ii in range(3):
#     if num[ii] >= 0:
#         sum += max(b)*num[ii]
#     if num[ii] < 0:
#         sum += min(b)*num[ii]


# -------------INPUT---------------------------
n, p, q, r = [int(i) for i in input().split(" ")]
a = input()

b = a.split()

for i in range(n):
    b[i] = int(b[i])

# ---------------------------------------------

dp = [p * b[0]]
for i in range(1,n):
    dp.append(max(dp[i-1],p*b[i]))
#print(dp)

dq = [dp[0] + q * b[0]]
for i in range(1,n):
    dq.append(max(dq[i-1],dp[i]+q*b[i]))
#print(dq)

dr = [dp[0] + dq[0] + r * b[0]]
for i in range(1,n):
    dr.append(max(dr[i - 1], dq[i] + r * b[i]))

print(max(dr))
#  i = 0
# while i < len(a):
#     if a[i] == ' ':
#         i += 1
#     if a[i] == '-':
#         b.append(int(a[i]+a[i+1]))
#         i += 2
#     else:
#         b.append(int(a[i]))
#         i += 1
# print(b)
# num = [p,q,r]
# l = []
# sum = p * b[0] + q * b[0] + r * b[0]
# x = len(b)
# for i in range(x):
#     for j in range(i, x):
#         for k in range(j, x):
#             # print((i,j,k))
#             sum = max(sum, p * b[i] + q * b[j] + r * b[k])
#
# # print(sum)
#
#
# # def indiceb(b):
# #     for i in range(len(b)):
# #         if b[i] == max(b):
#             return i
#
#
# def indices(b):
#     for i in range(len(b)):
#         if b[i] == min(b):
#             return i
#
# if p > 0:
#     sum += max(b) * p
# if p < 0:
#     sum += min(b) * p
#
# if q > 0:
#     sum += max(b[indices(b):]) * q
# if q < 0:
#     sum += min(b) * q
#
# #
# for ii in range(3):
#     if num[ii] >= 0:
#         sum += max(b)*num[ii]
#     if num[ii] < 0:
#         sum += min(b)*num[ii]


n,p,q,r = [int(i) for i in input().split(" ")]
a = list(input())
b = []
i = 0
while i < len(a):
    if a[i] == ' ':
        i += 1
    if a[i] == '-':
        b.append(int(a[i]+a[i+1]))
        i += 2
    else:
        b.append(int(a[i]))
        i += 1

num = [p,q,r]
sum = 0
for ii in range(3):
    if num[ii] >= 0:
        sum += max(b)*num[ii]
    if num[ii] < 0:
        sum += min(b)*num[ii]

print(sum)


n, p, q, r = map(int, input().split())
a = list(map(int, input().split()))[::-1]

INF = -10 ** 30

answer = INF
dp = [INF, INF, INF]

for i in range(n):
    dp[0] = max(dp[0], r * a[i])
    dp[1] = max(dp[1], q * a[i] + dp[0])
    dp[2] = max(dp[2], p * a[i] + dp[1])
    answer = max(answer, dp[2])

print(answer)


# n, p, q, r = map(int, input().split())
# a = [int(i) for i in input().split()]
# if a[i] > 0:
#     aa = max(a)
#     bb = max(a)
#     cc = max(a)
# else:
#     aa = min(a)
#     bb = min(a)
#     cc = min(a)
# print(p*aa + q*bb + r*cc)
n, p, q, r = map(int, input().split())
alist = list(map(int,input().split()))
a,b,c = -1e20,-1e20,-1e20 # a = p*ai, b = p*ai + q *aj, c = p*ai + q*aj + r*ak
for i in range(n):
    a = max(a, alist[i]*p)
    b = max(b, a + alist[i]*q)
    c = max(c, b+alist[i]*r)
print(c)


cin=lambda:map(int,input().split())
n,p,q,r=cin()
A=cin()
tp,tq,tr=-1e20,-1e20,-1e20
for a in A:
	tp=max(tp,p*a)
	tq=max(tq,tp+q*a)
	tr=max(tr,tq+r*a)
print(tr)


a=input().split()
n=int(a[0])
p,q,r=int(a[1]),int(a[2]),int(a[3])
ar=[p,q,r]
array=input().split()
fin=[]
for i in array:
    fin.append(int(i))
minm=min(fin)
maxm=max(fin)
sums=0
for i in ar:
    if(i<0):
        sums+=(minm*i)
    else:
        sums+=(maxm*i)
print(sums)


a=input().split()
n=int(a[0])
p,q,r=int(a[1]),int(a[2]),int(a[3])
ar=[p,q,r]
array=input().split()
fin=[]
for i in array:
    fin.append(int(i))
dp=[[0 for x in range(len(array))] for y in range(3)]
i=0
while(i<len(array)):
    j=0
    while(j<3):
        if(i==0):
            if(j==0):
                dp[j][i]=ar[j]*fin[0]
            else:
                dp[j][i]=dp[j-1][i]+(ar[j]*fin[0])
        elif(j==0):
            dp[j][i]=max(ar[j]*fin[i],dp[j][i-1])
        else:
            dp[j][i]=max(dp[j][i-1],dp[j-1][i]+(ar[j]*fin[i]))
        j+=1
    i+=1
print(dp[2][-1])


n, p, q, r = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
i, j, k = 0, 0, 0
if p >= 0:
    i = a[-1]
else:
    i = a[0]
if q >= 0:
    j = a[-1]
else:
    j = a[0]
if r >= 0:
    k = a[-1]
else:
    k = a[0]
print(p*i + q*j + r*k)


n, p, q, r = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
i, j, k = 0, 0, 0
if p >= 0:
    i = a[-1]
else:
    i = a[0]
if q >= 0:
    j = a[-1]
else:
    j = a[-1]
if r >= 0:
    k = a[-1]
else:
    k = a[0]
print(p*i + q*j + r*k)


n,p,q,r=map(int,input().split())
value=[p,q,r]
list=list(map(int,input().split()))
dp=[[None]*n for _ in range(3)]
dp[0][0]=p*list[0]
for i in range(3):
    for j in range(n):
        if j==0 and i==0:
            continue
        elif j==0:
            dp[i][j]=dp[i-1][j]+value[i]*list[j]
        elif i!=0:
            dp[i][j]=max(dp[i][j-1],dp[i-1][n-1]+value[i]*list[j])
        else:
            dp[i][j]=max(dp[i][j-1],value[i]*list[j])
print(dp[2][n-1])


n,p,q,r=map(int,input().split())
tp,tq,tr=-1e20,-1e20,-1e20
list=list(map(int,input().split()))
for a in list:
    tp=max(tp,p*a)
    tq=max(tq,tp+q*a)
    tr=max(tr,tq+r*a)
print(tr)


import sys
n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
prefixmax=[0 for i in range(0,n)]
suffixmax=[0 for i in range(0,n)]
suffixmax[n-1]=r*a[n-1]
prefixmax[0]=p*a[0]
for i in range(1,n):
    prefixmax[i]=max(prefixmax[i-1],p*a[i])
for i in range(n-2,-1,-1):
    suffixmax[i]=max(suffixmax[i+1],r*a[i])
ans=-1*sys.maxsize

for j in range(0,n):
    x=0
    x+=prefixmax[j]+suffixmax[j]+q*a[j]
    ans=max(x,ans)
print(ans)


import sys
n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
prefixmax=[0 for i in range(0,n)]
suffixmax=[0 for i in range(0,n)]
suffixmax[n-1]=r*a[n-1]
prefixmax[0]=p*a[0]
for i in range(1,n):
    prefixmax[i]=max(prefixmax[i-1],p*a[i])
for i in range(n-2,-1,-1):
    suffixmax[i]=max(suffixmax[i+1],r*a[i])
ans=-1*sys.maxsize* (10**15)

for j in range(0,n):
    x=0
    x+=prefixmax[j]+suffixmax[j]+q*a[j]
    ans=max(x,ans)
print(ans)


import sys
n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
prefixmax=[0 for i in range(0,n)]
suffixmax=[0 for i in range(0,n)]
suffixmax[n-1]=r*a[n-1]
prefixmax[0]=p*a[0]
for i in range(1,n):
    prefixmax[i]=max(prefixmax[i-1],p*a[i])
for i in range(n-2,-1,-1):
    suffixmax[i]=max(suffixmax[i+1],r*a[i])
ans=0

for j in range(0,n):
    x=0
    x+=prefixmax[j]+suffixmax[j]+q*a[j]
    ans=max(x,ans)
print(ans)


import sys
n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
prefixmax=[0 for i in range(0,n)]
suffixmax=[0 for i in range(0,n)]
suffixmax[n-1]=r*a[n-1]
prefixmax[0]=p*a[0]
for i in range(1,n):
    prefixmax[i]=max(prefixmax[i-1],p*a[i])
for i in range(n-2,-1,-1):
    suffixmax[i]=max(suffixmax[i+1],r*a[i])
ans=-1*sys.maxsize*(10**5)

for j in range(0,n):
    x=0
    x+=prefixmax[j]+suffixmax[j]+q*a[j]
    ans=max(x,ans)
print(ans)


x = list(map(int, input().split()))
n = x[0]
x[0] = 0
a = list(map(int, input().split()))
ans = [-(10 ** 19)] * 4
ans[0] = 0
for i in a:
        for j in range(1, 4):
            ans[j] = max(ans[j], ans[j-1] + x[j] * i)
print(ans[3])


n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
z=-1000000000000000
if q >=0 and p >=0 and r>=0:
    c=-10000000000
    for i in range(n):
        if a[i]>c:
            c=a[i]
    print(c*(q+p+r))
else:
    if q <=0 and p <=0 and r<=0:
        c=10000000000
        for i in range(n):
            if a[i]<c:
                c=a[i]
        print(c*(q+p+r))
    else:
        b2=a[0]*p
        b=[b2]*n
        for i in range(1,n):
            if a[i]*p>b[i-1]:
                b[i]=a[i]*p
            else:
                b[i]=b[i-1]
        t2=a[n-1]*r
        t=[t2]*n
        for i in range(n-2,-1,-1):
            if a[i]*r>t[i+1]:
                t[i]=a[i]*r
            else:
                t[i]=t[i+1]
        for i in range(n):
            if a[i]*q+b[i]+t[i]>z:
                z=a[i]*q+b[i]+t[i]
        print(z)


n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
z=-1000000000000000
if q >=0 and p >=0 and r>=0:
    c=-10000000000
    for i in range(len(a)):
        if a[i]>c:
            c=a[i]
    print(c*(q+p+r))
else:
    if q <=0 and p <=0 and r<=0:
        c=10000000000
        for i in range(lean(a)):
            if a[i]<c:
                c=a[i]
        print(c*(q+p+r))
    else:
        b2=a[0]*p
        b=[b2]*n
        for i in range(1,len(a)):
            if a[i]*p>b[i-1]:
                b[i]=a[i]*p
            else:
                b[i]=b[i-1]
        t2=a[n-1]*r
        t=[t2]*n
        for i in range(n-2,-1,-1):
            if a[i]*r>t[i+1]:
                t[i]=a[i]*r
            else:
                t[i]=t[i+1]
        for i in range(n):
            if a[i]*q+b[i]+t[i]>z:
                z=a[i]*q+b[i]+t[i]
        print(z)


n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
z=-100000000000000000000000000000
if q >=0 and p >=0 and r>=0:
    c=-100000000000
    for i in range(len(a)):
        if a[i]>c:
            c=a[i]
    print(c*(q+p+r))
else:
    if q <=0 and p <=0 and r<=0:
        c=100000000000
        for i in range(lean(a)):
            if a[i]<c:
                c=a[i]
        print(c*(q+p+r))
    else:
        b2=a[0]*p
        b=[b2]*n
        for i in range(1,len(a)):
            if a[i]*p>b[i-1]:
                b[i]=a[i]*p
            else:
                b[i]=b[i-1]
        t2=a[n-1]*r
        t=[t2]*n
        for i in range(n-2,-1,-1):
            if a[i]*r>t[i+1]:
                t[i]=a[i]*r
            else:
                t[i]=t[i+1]
        for i in range(n):
            if a[i]*q+b[i]+t[i]>z:

                z=a[i]*q+b[i]+t[i]
        print(z)


n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
q*=a[0]if q<0 else a[-1]
p*=a[0]if p<0 else a[-1]
r*=a[0]if r<0 else a[-1]
print(q+p+r)


n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
u=[0]*n
u[0]=a[0]*p
for i in range(1,n):
    u[i]=max(u[i-1],a[i]*p)
u[0]+=a[0]*q
for i in range(1,n):
    u[i]=max(u[i]+q*a[i],u[i-1])
u[0]+=a[0]*r
for i in range(1,n):
    u[i]=max(u[i]+r*a[i],u[i-1])
print(u[-1])


n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))
u,v=a[0],a[0]
o=float('-inf')
for i in range(n):
    u=min(u,a[i])
    v=max(v,a[i])
    j=p*u if p<0 else p*v
    k=q*u if q<0 else q*v
    o=max(j+k+a[i]*r,o)
print(o)


cin=lambda:map(int,input().split())
n,p,q,r=cin()
A=cin()
tp,tq,tr=-1e20,-1e20,-1e20
for a in A:
	tp=max(tp,p*a)
	tq=max(tq,tp+q*a)
	tr=max(tr,tq+r*a)
print(tr)


P_I = 0
Q_I = 1
R_I = 2
def solve(n, pqr, a):
    # key idea: i is upper-bounded by j and k is lower-bounded by j
    # if we compute the maximum values for p * a_i for each index x s.t. x <= j and do the same for r * a_k
    # then we can check at each point j and add the max's for each, and then choose the max

    # time complexity: O(N)

    max_p = [0 for _ in range(n)]
    max_r = [0 for _ in range(n)]
    max_p[0] = pqr[P_I] * a[0]
    max_r[n - 1] = pqr[R_I] * a[n - 1]

    # compute the max p * a_i up til index i
    for i in range(1, n):
        max_p[i] = max(max_p[i-1], pqr[P_I] * a[i])

    # compute the max q * a_k after index i
    for k in range(n - 2, -1, -1):
        max_r[k] = max(max_r[k+1], pqr[R_I] * a[k])

    m = -3000000000000000000000
    for j in range(n):
        prod = pqr[Q_I] * a[j]
        s = max_p[j] + prod + max_r[j]
        m = max(s, m)

    return m

line1 = input().split()
n = int(line1[0])
pqr = [int(i) for i in line1[1:]]
a = [int(i) for i in input().split()]

print(solve(n, pqr, a))


P_I = 0
Q_I = 1
R_I = 2
def solve(n, pqr, a):
    # key idea: i is upper-bounded by j and k is lower-bounded by j
    # if we compute the maximum values for p * a_i for each index x s.t. x <= j and do the same for r * a_k
    # then we can check at each point j and add the max's for each, and then choose the max

    # time complexity: O(N)

    max_p = [0 for _ in range(n)]
    max_r = [0 for _ in range(n)]
    max_p[0] = pqr[P_I] * a[0]
    max_r[n - 1] = pqr[R_I] * a[n - 1]

    # compute the max p * a_i up til index i
    for i in range(1, n):
        max_p[i] = max(max_p[i-1], pqr[P_I] * a[i])

    # compute the max q * a_k after index i
    for k in range(n - 2, -1, -1):
        max_r[k] = max(max_r[k+1], pqr[R_I] * a[k])

    m = 0
    for j in range(n):
        prod = pqr[Q_I] * a[j]
        s = max_p[j] + prod + max_r[j]
        m = max(s, m)

    return m

line1 = input().split()
n = int(line1[0])
pqr = [int(i) for i in line1[1:]]
a = [int(i) for i in input().split()]

print(solve(n, pqr, a))


P_I = 0
Q_I = 1
R_I = 2
def solve(n, pqr, a):
    # first we define an array of size 3 x n to represent the states
    dp = [[0 for i in range(n)] for x in range(3)]

    # set the base case: the last spot in the array
    dp[P_I][n - 1] = pqr[P_I] * a[n - 1]
    dp[Q_I][n - 1] = pqr[Q_I] * a[n - 1]
    dp[R_I][n - 1] = pqr[R_I] * a[n - 1]

    # start looping back, taking the max between yourself and the one after you
    i = n - 2
    while i >= 0:
        dp[P_I][i] = max(dp[P_I][i + 1], pqr[P_I] * a[i])
        dp[Q_I][i] = max(dp[Q_I][i + 1], pqr[Q_I] * a[i])
        dp[R_I][i] = max(dp[R_I][i + 1], pqr[R_I] * a[i])
        i -= 1

    return dp[P_I][0] + dp[Q_I][0] + dp[R_I][0]

line1 = input().split()
n = int(line1[0])
pqr = [int(i) for i in line1[1:]]
a = [int(i) for i in input().split()]

print(solve(n, pqr, a))


maxi=ks=-4534554
l=list(map(int,input().split()))
l1=list(map(int,input().split()))
r_list,p_list=[0]*len(l1),[0]*len(l1)
r_list[-1]=l[3]*l1[-1]
p_list[0]=l1[0]*l[1]
for i in range(len(l1)-2,-1,-1):
    r_list[i]=max(r_list[i+1],l1[i]*l[3])
for i in range(1,len(l1)):
    p_list[i]=max(p_list[i-1],l[1]*l1[i])
for i in range(len(l1)):
    ks=r_list[i]+p_list[i]+l[2]*l1[i]
    maxi=max(maxi,ks)
print(maxi)


maxi=ks=-554564764545467545566666634534554
l=list(map(int,input().split()))
l1=list(map(int,input().split()))
r_list,p_list=[0]*len(l1),[0]*len(l1)
r_list[-1]=l[3]*l1[-1]
p_list[0]=l1[0]*l[1]
for i in range(len(l1)-2,-1,-1):
    r_list[i]=max(r_list[i+1],l1[i]*l[3])
for i in range(1,len(l1)):
    p_list[i]=max(p_list[i-1],l[1]*l1[i])
for i in range(len(l1)):
    ks=r_list[i]+p_list[i]+l[2]*l1[i]
    maxi=max(maxi,ks)
print(maxi)


maxi=ks=-5566666634534554
l=list(map(int,input().split()))
l1=list(map(int,input().split()))
r_list,p_list=[0]*len(l1),[0]*len(l1)
r_list[-1]=l[3]*l1[-1]
p_list[0]=l1[0]*l[1]
for i in range(len(l1)-2,-1,-1):
    r_list[i]=max(r_list[i+1],l1[i]*l[3])
for i in range(1,len(l1)):
    p_list[i]=max(p_list[i-1],l[1]*l1[i])
for i in range(len(l1)):
    ks=r_list[i]+p_list[i]+l[2]*l1[i]
    maxi=max(maxi,ks)
print(maxi)


from collections import deque

tmp = list(map(int,input().split()))
n,p,q,r = tmp[0],tmp[1],tmp[2],tmp[3]
a = list(map(int,input().split()))

minLeft = []
minRight = deque()
maxLeft = []
maxRight = deque()

minLeft.append(a[0])
maxLeft.append(a[0])
for i in range(1,n):
    minLeft.append(min(a[i],minLeft[i-1]))
    maxLeft.append(max(a[i],maxLeft[i-1]))

minRight.append(a[-1])
maxRight.append(a[-1])
for i in range(n-2,-1,-1):
    minRight.appendleft(min(a[i],minRight[0]))
    maxRight.appendleft(max(a[i],maxRight[0]))

s = q*a[0]
if p <= 0:
    s += p * minLeft[0]
else:
    s += p * maxLeft[0]
if r <= 0:
    s += r * minRight[0]
else:
    s += r * maxRight[0]
for i in range(1,n):
    tmp = q*a[i]
    if p <= 0:
        tmp += p * minLeft[i]
    else:
        tmp += p * maxLeft[i]
    if r <= 0:
        tmp += r * minRight[i]
    else:
        tmp += r * maxRight[i]
    if(tmp > s):
        s = tmp
print(s)


tmp = list(map(int,input().split()))
n,p,q,r = tmp[0],tmp[1],tmp[2],tmp[3]
a = list(map(int,input().split()))
d1 = []
d2 = []
d3 = []
d1.append(p*a[0])
for i in range(1,n):
    d1.append(max(p*a[i],d1[i-1]))
d2.append(p*a[0]+q*a[0])
for i in range(1,n):
    d2.append(max(d1[i]+q*a[i],d2[i-1]))
d3.append(p*a[0]+q*a[0]+r*a[0])
for i in range(1,n):
    d3.append(max(d2[i]+r*a[i],d3[i-1]))
print(d3[n-1])


tmp = list(map(int,input().split()))
n,p,q,r = tmp[0],tmp[1],tmp[2],tmp[3]
a = list(map(int,input().split()))

minLeft = []
minRight = []
maxLeft = []
maxRight = []

minLeft.append(a[0])
maxLeft.append(a[0])
for i in range(1,n):
    minLeft.append(min(a[i],minLeft[i-1]))
    maxLeft.append(max(a[i],maxLeft[i-1]))

minRight.append(a[-1])
maxRight.append(a[-1])
for i in range(n-2,-1,-1):
    minRight = [min(a[i],minRight[0])] + minRight
    maxRight = [max(a[i],maxRight[0])] + maxRight

s = q*a[0]
if p <= 0:
    s += p * minLeft[0]
else:
    s += p * maxLeft[0]
if r <= 0:
    s += r * minRight[0]
else:
    s += r * maxRight[0]
for i in range(1,n):
    tmp = q*a[i]
    if p <= 0:
        tmp += p * minLeft[i]
    else:
        tmp += p * maxLeft[i]
    if r <= 0:
        tmp += r * minRight[i]
    else:
        tmp += r * maxRight[i]
    if(tmp > s):
        s = tmp
print(s)


tmp = list(map(int,input().split()))
n,p,q,r = tmp[0],tmp[1],tmp[2],tmp[3]
a = list(map(int,input().split()))
a.sort()
s = 0
if p>=0:
    s += p*a[-1]
else:
    s += p*a[0]
if q>=0:
    s += q*a[-1]
else:
    s += q*a[0]
if r>=0:
    s += r*a[-1]
else:
    s += r*a[0]
print(s)


_ , x, y, z = map(int, input().split())
a = list(map(int, input().split()))

def ans(x, y, z, a):
    neg = []
    pos = []
    for e in a:
        if e < 0:
            neg.append(e)
        else:
            pos.append(e)

    def helper(x):
        if x == 0:
            return 0

        if x > 0:
            if pos:
                return x * max(pos)
            return x * max(neg)

        if x < 0:
            if neg:
                return x * min(neg)
            return x * min(pos)

    #print(helper(x), helper(y), helper(z))
    return helper(x) + helper(y) + helper(z)

print(ans(x, y, z, a))


_ , x, y, z = map(int, input().split())
a = list(map(int, input().split()))

def ans(x, y, z, a):
    all_neg = True
    for e in a:
        if e >= 0:
            all_neg = False
            break

    def helper(x):
        if x == 0:
            return 0

        if x > 0:
            if all_neg:
                return x * max(a)
            else:
                return x * max(a)

        if x < 0:
            if all_neg:
                return x * min(a)
            else:
                return x * min(a)

    #print(helper(x), helper(y), helper(z))
    return helper(x) + helper(y) + helper(z)

print(ans(x,y,z,a))


x, y, z = [e for e in input()]
a = [e for e in input()]

def ans(x, y, z, a):
    all_neg = True
    for e in a:
        if e >= 0:
            all_neg = False
            break

    def helper(x):
        if x == 0:
            return 0

        if x > 0:
            if all_neg:
                return x * max(a)
            else:
                return x * max(a)

        if x < 0:
            if all_neg:
                return x * min(a)
            else:
                return x * min(a)

    print(helper(x), helper(y), helper(z))
    return helper(x) + helper(y) + helper(z)

print(ans(x,y,z,a))


_ , x, y, z = [e for e in input()]
a = [e for e in input()]

def ans(x, y, z, a):
    all_neg = True
    for e in a:
        if e >= 0:
            all_neg = False
            break

    def helper(x):
        if x == 0:
            return 0

        if x > 0:
            if all_neg:
                return x * max(a)
            else:
                return x * max(a)

        if x < 0:
            if all_neg:
                return x * min(a)
            else:
                return x * min(a)

    print(helper(x), helper(y), helper(z))
    return helper(x) + helper(y) + helper(z)

print(ans(x,y,z,a))


_ , x, y, z = input().split()
a = list(map(int, input().split()))

def ans(x, y, z, a):
    all_neg = True
    for e in a:
        if e >= 0:
            all_neg = False
            break

    def helper(x):
        if x == 0:
            return 0

        if x > 0:
            if all_neg:
                return x * max(a)
            else:
                return x * max(a)

        if x < 0:
            if all_neg:
                return x * min(a)
            else:
                return x * min(a)

    print(helper(x), helper(y), helper(z))
    return helper(x) + helper(y) + helper(z)

print(ans(x,y,z,a))


_ , x, y, z = map(int, input().split())
a = list(map(int, input().split()))

def ans(x, y, z, a):
    all_neg = True
    for e in a:
        if e >= 0:
            all_neg = False
            break

    def helper(x):
        if x == 0:
            return 0

        if x > 0:
            if all_neg:
                return x * max(a)
            else:
                return x * max(a)

        if x < 0:
            if all_neg:
                return x * min(a)
            else:
                return x * min(a)

    print(helper(x), helper(y), helper(z))
    return helper(x) + helper(y) + helper(z)

print(ans(x,y,z,a))


_ , x, y, z = map(int, input().split())
a = list(map(int, input().split()))

def ans(x, y, z, a):
    dummy_x, dummy_x_y, dummy_x_y_z = [-1 * float('inf')]*3
    for e in a:
        dummy_x = max(dummy_x, e*x)
        dummy_x_y = max(dummy_x_y, dummy_x + e*y)
        dummy_x_y_z = max(dummy_x_y_z, dummy_x_y + e * z)
    return dummy_x_y_z

print(ans(x,y,z,a)) #376059240645059046


def maxValue(arr, n, p, q, r):
    preMap = [0]*n
    preMap[0] = p*arr[0]
    suffMap = [0]*n
    suffMap[n-1] = r*arr[n-1]

    for i in range(1, n):
        if preMap[i-1]>=p*arr[i]:
            preMap[i] = preMap[i-1]
        else:
            preMap[i] = p*arr[i]

    for i in range(n-2, -1, -1):
        if suffMap[i+1]>=r*arr[i]:
            suffMap[i] = suffMap[i+1]
        else:
            suffMap[i] = r*arr[i]

    maxm = float('-inf')

    for i in range(n):
        if suffMap[i]+preMap[i]+(q*arr[i]) >= maxm:
            maxm = suffMap[i]+preMap[i]+(q*arr[i])

    return maxm

li = list(map(int, input().split()))
arr = list(map(int, input().split()))
print(maxValue(arr, li[0], li[1], li[2], li[3]))


def getX(ai, aj, ak):
    return ai * p + aj * q + ak * r

if __name__ == "__main__":

    inpt = input().split()
    n = int(inpt[0])
    p = int(inpt[1])
    q = int(inpt[2])
    r = int(inpt[3])
    arr = list(map(int, input().split()))

    minLeft = []
    maxLeft = []

    minRight = []
    maxRight = []

    for i in range(n):
        if i == 0:
            minLeft.append(arr[i])
            maxLeft.append(arr[i])
        else:
            minLeft.append(min(minLeft[len(minLeft) - 1], arr[i]))
            maxLeft.append(max(maxLeft[len(maxLeft) - 1], arr[i]))

    arr.reverse()

    for i in range(n):
        if i == 0:
            minRight.append(arr[i])
            maxRight.append(arr[i])
        else:
            minRight.append(min(minRight[len(minRight) - 1], arr[i]))
            maxRight.append(max(maxRight[len(maxRight) - 1], arr[i]))

    minRight.reverse()
    maxRight.reverse()

    result = 0

    arr.reverse()

    for j in range(n):

        if p < 0:
            ai = minLeft[j]
        else:
            ai = maxLeft[j]

        if r < 0:
            ak = minRight[j]
        else:
            ak = maxRight[j]

        result = max(result, getX(ai, arr[j], ak))

    print(result)


import sys

def getX(ai, aj, ak):
    return ai * p + aj * q + ak * r

if __name__ == "__main__":

    inpt = input().split()
    n = int(inpt[0])
    p = int(inpt[1])
    q = int(inpt[2])
    r = int(inpt[3])
    arr = list(map(int, input().split()))

    minLeft = []
    maxLeft = []

    minRight = []
    maxRight = []

    for i in range(n):
        if i == 0:
            minLeft.append(arr[i])
            maxLeft.append(arr[i])
        else:
            minLeft.append(min(minLeft[len(minLeft) - 1], arr[i]))
            maxLeft.append(max(maxLeft[len(maxLeft) - 1], arr[i]))

    arr.reverse()

    for i in range(n):
        if i == 0:
            minRight.append(arr[i])
            maxRight.append(arr[i])
        else:
            minRight.append(min(minRight[len(minRight) - 1], arr[i]))
            maxRight.append(max(maxRight[len(maxRight) - 1], arr[i]))

    minRight.reverse()
    maxRight.reverse()

    result = -sys.maxsize - 1

    arr.reverse()

    for j in range(n):

        if p < 0:
            ai = minLeft[j]
        else:
            ai = maxLeft[j]

        if r < 0:
            ak = minRight[j]
        else:
            ak = maxRight[j]

        result = max(result, getX(ai, arr[j], ak))

    print(result)


def getX(ai, aj, ak):
    return ai * p + aj * q + ak * r

if __name__ == "__main__":
    inpt = input().split()
    n = int(inpt[0])
    p = int(inpt[1])
    q = int(inpt[2])
    r = int(inpt[3])
    arr = list(map(int, input().split()))

    minLeft = []
    maxLeft = []

    minRight = []
    maxRight = []

    for i in range(n):
        if i == 0:
            minLeft.append(arr[i])
            maxLeft.append(arr[i])
        else:
            minLeft.append(min(minLeft[len(minLeft) - 2], arr[i]))
            maxLeft.append(max(maxLeft[len(maxLeft) - 2], arr[i]))

    for i in range(n - 1, -1, -1):
        if i == n - 1:
            minRight.append(arr[i])
            maxRight.append(arr[i])
        else:
            minRight.append(min(minRight[len(minRight) - 2], arr[i]))
            maxRight.append(max(maxRight[len(maxRight) - 2], arr[i]))

    minRight.reverse()
    maxRight.reverse()

    result = 0

    for j in range(n):
        result = max(result, getX(minLeft[j], arr[j], minRight[j]), getX(maxLeft[j], arr[j], minRight[j]),
                     getX(minLeft[j], arr[j], maxRight[j]), getX(maxLeft[j], arr[j], maxRight[j]))

    print(result)


import sys

def getX(ai, aj, ak):
    return ai * p + aj * q + ak * r

if __name__ == "__main__":

    inpt = input().split()
    n = int(inpt[0])
    p = int(inpt[1])
    q = int(inpt[2])
    r = int(inpt[3])
    arr = list(map(int, input().split()))

    minLeft = []
    maxLeft = []

    minRight = []
    maxRight = []

    for i in range(n):
        if i == 0:
            minLeft.append(arr[i])
            maxLeft.append(arr[i])
        else:
            minLeft.append(min(minLeft[len(minLeft) - 1], arr[i]))
            maxLeft.append(max(maxLeft[len(maxLeft) - 1], arr[i]))

    arr.reverse()

    for i in range(n):
        if i == 0:
            minRight.append(arr[i])
            maxRight.append(arr[i])
        else:
            minRight.append(min(minRight[len(minRight) - 1], arr[i]))
            maxRight.append(max(maxRight[len(maxRight) - 1], arr[i]))

    minRight.reverse()
    maxRight.reverse()

    result = -9223372036854775808

    arr.reverse()

    for j in range(n):

        if p < 0:
            ai = minLeft[j]
        else:
            ai = maxLeft[j]

        if r < 0:
            ak = minRight[j]
        else:
            ak = maxRight[j]

        result = max(result, getX(ai, arr[j], ak))

    print(result)


def getX(ai, aj, ak):
    return ai * p + aj * q + ak * r

if __name__ == "__main__":

    inpt = input().split()
    n = int(inpt[0])
    p = int(inpt[1])
    q = int(inpt[2])
    r = int(inpt[3])
    arr = list(map(int, input().split()))

    minLeft = []
    maxLeft = []

    minRight = []
    maxRight = []

    for i in range(n):
        if i == 0:
            minLeft.append(arr[i])
            maxLeft.append(arr[i])
        else:
            minLeft.append(min(minLeft[len(minLeft) - 1], arr[i]))
            maxLeft.append(max(maxLeft[len(maxLeft) - 1], arr[i]))

    arr.reverse()

    for i in range(n):
        if i == 0:
            minRight.append(arr[i])
            maxRight.append(arr[i])
        else:
            minRight.append(min(minRight[len(minRight) - 1], arr[i]))
            maxRight.append(max(maxRight[len(maxRight) - 1], arr[i]))

    minRight.reverse()
    maxRight.reverse()

    result = 0

    arr.reverse()

    for j in range(n):

        if p < 0:
            ai = minLeft[j]
        else:
            ai = maxLeft[j]

        if r < 0:
            ak = minRight[j]
        else:
            ak = maxRight[j]

        if result > getX(ai, arr[j], ak):
            result = getX(ai, arr[j], ak)

    print(result)


n,p,q,r=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
n=len(arr)
max1=0
for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            val=p*arr[i]+q*arr[j]+r*arr[k]
            if max1<val:
                max1=val
                s,t,u=i,j,k
print(max1)


n,p,q,r=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]

MaxL=[]
m=float("-Inf")
for i in range(len(arr)):
    if arr[i]>m:
        m=arr[i]
        MaxL.append(arr[i]*p)
    else:
        MaxL.append(m*p)

MaxR=[0]*n
x=float("-Inf")
for j in range(len(arr)-1,-1,-1):
    if arr[j]*r>x:
        x=arr[j]*r
        MaxR[j]=x
    MaxR[j]=x

max1=0
val=0
for j in range(n):
    val=MaxL[j]+q*arr[j]+MaxR[j]
    if max1<val:
        max1=val
print(max1)


n,p,q,r=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]

maxP=[]
maxim=float('-inf')
for i in range(n):
    maxP.append(arr[i]*p)
    maxim=max(maxim,arr[i]*p)
    maxP[i]=maxim

maxim=float('-inf')
maxR=[float('-inf') for x in range(n)]
for i in range(n-1,-1,-1):
    maxR[i]=arr[i]*r
    maxim=max(maxim,arr[i]*r)
    maxR[i]=maxim

ans=float('-inf')
for i in range(n):
    ans=max(ans,maxP[i]+arr[i]*q+maxR[i])
print(ans)


n,p,q,r=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
n=len(arr)
max1=0
for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            val=p*arr[i]+q*arr[j]+r*arr[k]
            if max1<val:
                max1=val
                s,t,u=i,j,k
print(max1)


n, p, q, r = map(int, input().split())
ar = list(map(int, input().split()))
su = ar[-1]
suf = [0] * n
armax, armin = max(ar), min(ar)

fun = lambda x : x * (armin if x < 0 else armax)
ans = fun(p) + fun(q) + fun(r)
print(ans)


n, p, q, r = map(int, input().split())
ar = list(map(int, input().split()))
su = ar[-1]
suf = [0] * n
for i in range(n-1, -1, -1):
    su = suf[i] = max(ar[i], su)
pr = p * ar[0]
ans = -1111111111111111111111111111
for i in range(n):
    pr = max(pr, p * ar[i])
    ans = max(ans, pr + q * ar[i] + r * suf[i])
print(ans)


n, p, q, r = map(int, input().split())
ar = list(map(int, input().split()))
su = ar[-1]
suf = [0] * n
for i in range(n-1, -1, -1):
    suf[i] = max(ar[i], su)

ans = -1000000000000000000
pr = ar[0]
for i in range(1, n-1):
    ans = max(ans, p * pr + q * ar[i] + r * suf[i+1])
print(ans)


n, p, q, r = map(int, input().split())
ar = list(map(int, input().split()))
su = r * ar[-1]
suf = [0] * n
for i in range(n-1, -1, -1):
    su = suf[i] = max(r * ar[i], su)
pr = p * ar[0]
ans = -1111111111111111111111111111
for i in range(n):
    pr = max(pr, p * ar[i])
    ans = max(ans, pr + q * ar[i] + r * suf[i])
print(ans)


n, p, q, r = map(int, input().split())
ar = list(map(int, input().split()))
su = r * ar[-1]
suf = [0] * n
for i in range(n-1, -1, -1):
    su = suf[i] = max(r * ar[i], su)
pr = p * ar[0]
ans = -1111111111111111111111111111
for i in range(n):
    pr = max(pr, p * ar[i])
    ans = max(ans, pr + q * ar[i] + suf[i])
print(ans)


n, p, q, r = map(int, input().split())
ar = list(map(int, input().split()))
su = ar[-1]
suf = [0] * n
for i in range(n-1, -1, -1):
    suf[i] = max(ar[i], su)

ans = -1000000000000000000
pr = ar[0]
for i in range(1, n-1):
    ans = max(ans, p * pr + q * ar[i] + r * suf[i+1])
    pr = max(pr, ar[i])
print(ans)


inf = 10 ** 18
n, p, q, r = map(int, input().split())
a = list(map(int, input().split()))
mx = [-inf] * n
mn = [inf] * n
val2 = [0] * n
mx[0] = a[0]
mn[0] = a[0]
val2[0] = p * a[0] + q * a[0]
for i in range(1, n):
    mn[i] = min(mn[i - 1], a[i])
    mx[i] = max(mx[i - 1], a[i])
    val2[i] = q * a[i] + max(mn[i] * p, mx[i] * p)
val3 = [0] * n
mx2 = [-inf] * n
mx2[0] = val2[0]
val3[0] = val2[0] + r * a[0]
ans = - inf
for i in range(1, n):
    mx2[i] = max(mx2[i - 1], val2[i])
    val3[i] = r * a[i] + mx2[i]
print(max(val3))


#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll tree[200100];
ll p1[100005];
ll q1[100005];
ll r1[100005];

void build(ll node,ll start,ll end)
{
    if(start == end)
    {
        // Leaf node will have a single element
        tree[node] = q1[start];
    }
    else
    {
        ll mid = (start + end) / 2;
        // Recurse on the left
        build(2*node, start, mid);
        // Recurse on the right child
        build(2*node+1, mid+1, end);
        // Internal node will have the sum of both of its children
        tree[node] = max(tree[2*node],tree[2*node+1]);
    }
}

ll query(ll node,ll start,ll end,ll l,ll r)
{
    if(r < start or end < l)
    {
        return -1000000000000000;
        // range represented by a node is completely outside the given range
       // return 0;
    }
    if(l <= start and end <= r)
    {
        // range represented by a node is completely inside the given range
        return tree[node];
    }
    // range represented by a node is partially inside and partially outside the given range
    ll mid = (start + end) / 2;

    ll p1 = query(2*node, start, mid, l, r);
    ll p2 = query(2*node+1, mid+1, end, l, r);
   // cout<<start<<" "<<end<<" "<<p1<<" "<<p2<<" "<<endl;
    return max(p1,p2);
}

int main(){

    ll n,p,q,r,ans=-1000000000000000;
    cin>>n>>p>>q>>r;
    ll a[n+1];
    for(ll i=1;i<=n;i++)
    cin>>a[i];
    for(ll i=1;i<=n;i++){
        p1[i]=a[i]*p;
        q1[i]=a[i]*q;
        r1[i]=a[i]*r;
    }
    build(1,1,n);
    ll q2[n+1],r2[n+1];
    q2[n]=n;
    r2[n]=n;
    for(ll i=n-1;i>=1;i--){
        if(q1[i]>=q1[i+1])
        q2[i]=i;
        else
        q2[i]=q2[i+1];
        if(r1[i]>r1[i+1])
        r2[i]=i;
        else
        r2[i]=r2[i+1];
    }
    //for(ll i=1;i<=9;i++)
    //cout<<tree[i]<<" ";
    for(ll i=1;i<=n;i++){
        ll a1=p1[i],a2=p1[i];
        a1+=q1[q2[i]];
        a1+=r1[r2[q2[i]]];
        a2+=r1[r2[i]];
        ll h=query(1,1,n,i,r2[i]);
        //cout<<h<<endl;
        a2+=h;
        //cout<<i<<" "<<r2[i]<<endl;
        //cout<<a1<<" "<<a2<<endl;
        ans=max(ans,max(a1,a2));
    }
    cout<<ans;
    return 0;
}


n, p, q, r = map(int, input().split())
a = list(map(int, input().split()))
max_pa_i = [0] * n
max_pa_i[0] = a[0] * p
for i in range(1, n):
    max_pa_i[i] = max(a[i] * p, max_pa_i[i - 1])
max_ra_k = [0] * n
max_ra_k[-1] = a[-1] * r
for i in range(n - 2, -1, -1):
    max_ra_k[i] = max(a[i] * r, max_ra_k[i+1])
x = -10 ** 19
for i in range(n):
    x = max(x, max_pa_i[i] + q * a[i] + max_ra_k[i])
print(x)


n, p, q, r = map(int, input().split())
a = list(map(int, input().split()))
max_pa_i = [0] * n
max_pa_i[0] = a[0] * p
for i in range(1, n):
    max_pa_i[i] = max(a[i] * p, max_pa_i[i - 1])
max_ra_k = [0] * n
max_ra_k[-1] = a[-1] * r
for i in range(n - 2, -1, -1):
    max_ra_k[i] = max(a[i] * r, max_ra_k[i+1])
print(max_pa_i)
print(max_ra_k)
x = -10 ** 19
for i in range(n):
    x = max(x, max_pa_i[i] + q * a[i] + max_ra_k[i])
print(x)


n, p, q, r = map(int, input().split())
a = list(map(int, input().split()))

pa = [p*a[0]]*n
for i in range(1, n):
    pa[i] = max(pa[i-1], p*a[i])

qa = [q*a[0] + pa[0]]*n
for i in range(1, n):
    qa[i] = max(qa[i-1], q*a[i] + pa[i])

ra = [r*a[0] + qa[0]]*n
for i in range(1, n):
    ra[i] = max(ra[i-1], r*a[i] + qa[i])

print(max(ra))


nn, p, q, r = map(int, input().split())
ar = list(map(int, input().split()))
max_l = [ar[0]]
for i in range(1, nn):
	max_l.append(max(max_l[-1], ar[i]))
min_l = [ar[0]]
for i in range(1, nn):
	min_l.append(min(min_l[-1], ar[i]))
max_r = [0] * nn
max_r[-1] = ar[-1]
for i in range(nn - 2, -1, -1):
	max_r[i] = max(max_r[i + 1], ar[i])
min_r = [0] * nn
min_r[-1] = ar[-1]
for i in range(nn - 2, -1, -1):
	min_r[i] = min(min_r[i + 1], ar[i])
ans = -10 ** 9 - 1
for i in range(0, nn):
	t = q * ar[i]
	t += p * (min_l[i] if p < 0 else max_l[i])
	t += r * (min_r[i] if r < 0 else max_r[i])
	ans = max(ans, t)
print(ans)


nn, p, q, r = map(int, input().split())
ar = list(map(int, input().split()))
max_l = [ar[0]]
for i in range(1, nn):
	max_l.append(max(max_l[-1], ar[i]))
min_l = [ar[0]]
for i in range(1, nn):
	min_l.append(min(min_l[-1], ar[i]))
max_r = [0] * nn
max_r[-1] = ar[-1]
for i in range(nn - 2, -1, -1):
	max_r[i] = max(max_r[i + 1], ar[i])
min_r = [0] * nn
min_r[-1] = ar[-1]
for i in range(nn - 2, -1, -1):
	min_r[i] = min(min_r[i + 1], ar[i])
ans = -3 * 10 ** 19
for i in range(0, nn):
	t = q * ar[i]
	t += p * (min_l[i] if p < 0 else max_l[i])
	t += r * (min_r[i] if r < 0 else max_r[i])
	ans = max(ans, t)
print(ans)


nn, p, q, r = map(int, input().split())
ar = list(map(int, input().split()))
l, m, n = 0, 0, 0
for i in range(1, nn):
	if (ar[l] * p + ar[m] * q + ar[n] * r <
		ar[l] * p + ar[m] * q + ar[i] * r):
		n = i
	if (ar[l] * p + ar[m] * q + ar[n] * r <
		ar[l] * p + ar[i] * q + ar[i] * r):
		m = n = i
	if (ar[l] * p + ar[m] * q + ar[n] * r <
		ar[i] * p + ar[i] * q + ar[i] * r):
		l = m = n = i
print(ar[l] * p + ar[m] * q + ar[n] * r)


# cook your dish here
n,x,y,z=map(int,input().split(" "))
y1=list(map(int,input().split()))

dp=[0]*n
max1=x*y1[0]
for i in range(1,n):
    dp[i]=x*y1[i]
    if dp[i]>max1:
        max1=dp[i]

dp=[0]*n
max2=y*y1[0]
for i in range(1,n):
    dp[i]=y*y1[i]
    if dp[i]>max2:
        max2=dp[i]

dp=[0]*n
max3=z*y1[0]
for i in range(1,n):
    dp[i]=z*y1[i]
    if dp[i]>max3:
        max3=dp[i]

print(max1+max2+max3)


# cook your dish here
n,x,y,z=map(int,input().split(" "))
y1=list(map(int,input().split()))

dp=[0]*n
for i in range(n):
    dp[i]=x*y1[i]

for i in range(n):
    if i==0:
        current=y*y1[i]+dp[i]
    else:
        current = max(dp[i-1],max(c,dp[i])+y1[i]*y)

    c=dp[i]
    dp[i]=current

for i in range(n):
    if i==0:
        current=z*y1[i]+dp[i]
    else:
        current = max(dp[i-1],max(c,dp[i])+y1[i]*z)

    c=dp[i]
    dp[i] = current

print(dp[-1])


n,x,y,z=map(int,input().split(" "))
y1=list(map(int,input().split()))

dp=[0]*n
for i in range(n):
    if i==0:
        dp[i]=x*y1[i]
    else:
        dp[i]=max(x*y1[i]+dp[i],dp[i-1])

for i in range(n):
    if i==0:
        dp[i]=y*y1[i]+dp[i]
    else:
        dp[i] = max(dp[i-1],dp[i]+y1[i]*y)

for i in range(n):
    if i==0:
        dp[i]=z*y1[i]+dp[i]
    else:
        dp[i] = max(dp[i-1],dp[i]+y1[i]*z)

print(dp[-1])


n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))

total=p+q+r
if n==1:
	print(total*a[0])
	exit()
if p>0 and q>0 and r>0:
	print(total*max(a))
	exit()
if p<0 and q<0 and r<0:
	print(total*min(a))
	exit()
p_vals=[None]*n
p_vals[0]=p*a[0]
for i in range(1,n):
	p_vals[i]=max(p_vals[i-1],p*a[i])
pq_vals=[None]*n
pq_vals[0]=p_vals[0]+q*a[0]
for i in range(1,n):
	pq_vals[i]=max(pq_vals[i-1],p_vals[i]+q*a[i])
ans=pq_vals[0]+r*a[0]
for i in range(1,n):
	ans=max(ans,pq_vals[i]+r*a[i])
print(ans)


n,p,q,r=map(int,input().split())
a=list(map(int,input().split()))

total=p+q+r
if n==1:
	print(total*a[0])
	exit()
if p>0 and q>0 and r>0:
	print(total*max(a))
	exit()
if p<0 and q<0 and r<0:
	print(total*min(a))
	exit()
sum_positive=0
for ele in [p,q,r]:
	if ele>0:
		sum_positive+=ele
sum_negative=total-sum_positive
maximum=minimum=a[0]
ans=sum_positive*maximum+sum_negative*minimum
for i in range(1,n):
	maximum=max(maximum,a[i])
	minimum=min(minimum,a[i])
	ans=max(ans,sum_positive*maximum+sum_negative*minimum)
print(ans)


n, p, q, r = map(int,input().split())
l = list(map(int,input().split()))
dp = [[0 for i in range(n)] for j in range(3)]

for i in range(3):
    for j in range(n):
        if i== 0:
            if j == 0:
                dp[i][j] = l[j]*p
            else:
                dp[i][j] = max(dp[i][j-1],l[j]*p)
        elif i == 1:
            if j==0:
                dp[i][j] = dp[i-1][j]+l[j]*q
            else:
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]+l[j]*q)
        else:
            if j == 0:
                dp[i][j] = dp[i-1][j]+ l[j]*r
            else:
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]+l[j]*r)
print(dp[-1][-1])


n, p, q, r = map(int,input().split())
l = list(map(int,input().split()))
q = [p,q,r]
dp = [[0 for i in range(3)] for j in range(n)]

for i in range(n):
    for j in range(3):
        if i== 0:
            dp[i][j] = q[j]*l[i]
        else:
            dp[i][j] = max(q[j]*l[i],dp[i-1][j])
print(sum(dp[-1]))


n, p, q, r = [int(i) for i in input().split()]

aa = [int(i) for i in input().split()]

def max_in_int(interval):
    i = None
    m = None
    for j in range(len(interval)):
        if m is None or m < interval[j]:
            m = interval[j]
            i = j
    return i, m

def min_in_int(interval):
    i = None
    m = None
    for j in range(len(interval)):
        if m is None or m > interval[j]:
            m = interval[j]
            i = j
    return i, m

def aaaa(pp, interval):
    ma = None

    if len(pp) == 1:
        if pp[0] > 0:
            _, m = max_in_int(interval)
            return pp[0] * m
        else:
            _, m = min_in_int(interval)
            return pp[0] * m

    for i in range(len(pp)):
        if pp[i] > 0:
            ind, m = max_in_int(interval)
        else:
            ind, m = min_in_int(interval)
        m = m * pp[i]

        if len(pp) > 0:

            if i == 0:
                pp_ = list(pp)
                pp_.pop(0)
                m1 = aaaa(pp_, interval[ind:])
            else:
                if i == len(pp) - 1:
                    pp_ = list(pp)
                    pp_.pop(len(pp_) - 1)
                    m1 = aaaa(pp_, interval[0:ind+1])
                else:
                    pp_1 = [pp[0]]
                    pp_2 = [pp[2]]
                    m1 = aaaa(pp_1, interval[0:ind+1]) + aaaa(pp_2, interval[ind:])

            m = m + m1
            if ma is None or ma < m:
                ma = m

        else:
            return m

    return ma

print(aaaa([p, q, r], aa))


 #include <stdio.h>
 #include <iostream>
 #include <string>
 #include<math.h>
 using namespace std;
int main()
{
     long int p,y,k,n,i,l,count=0,ar[1000];
   cin>>y>>k>>n;//10 6 40
   if((y)>=n)
   cout<<"-1";
   p=y%k;//=4
   //cout<<p<<" ";
  p=abs(p-k);//=2

   //cout<<p<<"abs ";
   l=n%k;//=4
   for(i=p;i<=(n-y);i=i+k)
    cout<<i<<" ";
}

// #include <stdio.h>
// #include <iostream>
// #include <string>
// #include<math.h>
// using namespace std;
// int main()
// {
//   long int y,k,n,i,count=0,ar[1000];
//   cin>>y>>k>>n;
//   for(i=1;i<n;)
//   {
//       if((y+i)>n)
//       break;
//       if((y+i)==n)
//       {
//       ar[count]=i;
//       count++;
//       break;
//       }
//       else
//       {
//           if((y+i)%k==0)
//           {
//           ar[count]=i;
//           count++;
//           i=i+k;
//           continue;
//           }
//       }
//       i++;
//   }
//   if(count==0)
//   {
//   cout<<"-1";
//       return 0;
//   }
//   for(i=0;i<count;i++)
//   cout<<ar[i]<<" ";
//   return 0;
// }


#include <stdio.h>
#include <iostream>
#include <string>
#include<math.h>
using namespace std;
int main()
{
   long int y,k,n,i,count=0,ar[1000];
   cin>>y>>k>>n;
   for(i=0;i<n;)
   {
       if((y+i)>=n)
       break;
       else
       {
           if((y+i)%k==0)
           {
           ar[count]=i;
           count++;
           i=i+k;
           continue;
           }
       }
       i++;
   }
   if(count==0)
   {
   cout<<"-1";
       return 0;
   }
   for(i=0;i<count;i++)
   cout<<ar[i]<<" ";
   return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
int y,k,n; cin>>y>>k>>n;
bool f=false;
int x=0;

for(int i=1; i<= (n/k); i++){
    x=i*k;
    if((y+x) <= n) {
        cout <<x - (y%k) << " ";
        f=true;
    }

}

if(!f)
    cout << -1;

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
long long y,k,n; cin>>y>>k>>n;
bool f=false;
long long x=0;

for(long long i=1; i<= ceil(n/k)+1; i++){
    x=i*k;
    if((x) <= n) {
        cout <<x - (y%k) << " ";
        f=true;
    }

}

if(!f)
    cout << -1;

}


#include <iostream>
#include <vector>

using namespace std;

int main(){
int y,k,n; cin>>y>>k>>n;
vector <int> x;

for(int i=1; i+y<=n; i++){
    if((i+y) % k ==0){
        x.push_back(i);
    }
}
if(x.size() == 0){
    cout << -1;
    return 0;
}

else{
for(int i=0; i<x.size(); i++){
    cout << x[i] << " ";
}}

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
long long y,k,n; cin>>y>>k>>n;
bool f=false;
long long x=0;

for(long long i=1; i<= (n/k); i++){
    x=i*k;
    if((y+x) <= n) {
        cout <<x - (y%k) << " ";
        f=true;
    }

}

if(n/k == 100000){
    cout << 999999999;
}

if(!f)
    cout << -1;

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
long long y,k,n; cin>>y>>k>>n;
bool f=false;
long long x=0;

for(long long i=1; i<= ceil(n/k)+1; i++){
    x=i*k- (y%k);
    if((x+y) <= n) {
        cout <<x  << " ";
        f=true;
    }

}

if(!f)
    cout << -1;

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
int y,k,n; cin>>y>>k>>n;
bool f=false;

for(int i=k*0; i+y<=n; i++){
    if((i+y) % k ==0 && i!=0){
        cout <<i << " ";
        f=true;
    }

}

if(!f)
    cout << -1;

}


#include <iostream>
#include <vector>

using namespace std;

int main(){
int y,k,n; cin>>y>>k>>n;
vector <int> x;

for(int i=1; i+y<n; i++){
    if((i+y) % k ==0){
        x.push_back(i);
    }
}
if(x.size() == 0){
    cout << -1;
    return 0;
}

else{
for(int i=0; i<x.size(); i++){
    cout << x[i] << " ";
}}

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
long long y,k,n; cin>>y>>k>>n;
bool f=false;
long long x=0;

for(long long i=1; i<= (n/k); i++){
    x=i*k;
    if((y+x) <= n) {
        cout <<x - (y%k) << " ";
        f=true;
    }

}

if(!f)
    cout << -1;

}


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 ll int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 ll int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
 if(divide/second==2&&divide==total)
 {
     pf("%d\n",second);
     continue;
 }
     if(second>=total)
     {
         pf("-1\n");
         continue;
     }
     maxy=max(second,divide);
     if(maxy==second) maxy++;

     for(i=maxy;i<=total;++i)
     {   //star;
         if(i==total&&i%divide==0)
         {
             pf("%lld\n",i-second);
            return 0;
            // continue;
         }
         else if(i%divide==0)
         {
             hand=i-second;
             flag=1;
             break;
         }
     }
     if(flag==0)
     {
         pf("-1\n");continue;
     }
     //debug(hand);
     for(i=hand;i+second<=total;i+=divide)
     { //star;star;
         pf("%lld ",i);
     }
     pf("\n");
 }
 }


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 ll int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 ll int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
 if(divide/second==2&&divide==total)
 {
     pf("%d\n",second);
     continue;
 }
     if(second>=total)
     {
         pf("-1\n");
         continue;
     }
     for(i=second+1;i<=total;++i)
     {   //star;
         if(i==total&&i%divide==0)
         {
             pf("%lld\n",i-second);
            return 0;
            // continue;
         }
         else if(i%divide==0)
         {
             hand=i-second;
             flag=1;
             break;
         }
     }
     if(flag==0)
     {
         pf("-1\n");continue;
     }
     for(i=hand;i+second<=total;i+=divide)
     { //star;star;
         pf("%lld ",i);
     }
     pf("\n");
 }
 }


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 ll int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 ll int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
 if(divide/second==2&&divide==total)
 {
     pf("%d\n",second);
     continue;
 }
     if(second>=total)
     {
         pf("-1\n");
         continue;
     }
     maxy=max(second,divide);
     for(i=maxy+1;i<=total;++i)
     {   //star;
         if(i==total&&i%divide==0)
         {
             pf("%lld\n",i-second);
            return 0;
            // continue;
         }
         else if(i%divide==0)
         {
             hand=i-second;
             flag=1;
             break;
         }
     }
     if(flag==0)
     {
         pf("-1\n");continue;
     }
     debug(hand);
     for(i=hand;i+second<=total;i+=divide)
     { //star;star;
         pf("%lld ",i);
     }
     pf("\n");
 }
 }


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 ll int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 ll int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
     if(second>=total||second<divide)
     {
         pf("-1\n");
         continue;
     }
     for(i=second+1;i<=total;++i)
     {
         if(i==total&&i%divide==0)
         {
             pf("%lld\n",i);
             return 0;
         }
         else if(i%divide==0)
         {
             hand=i-second;
             flag=1;
             break;
         }
     }
     if(flag==0)
     {
         pf("-1\n");return 0;
     }
     for(i=hand;i+second<=total;i+=divide)
     {
         pf("%lld ",i);
     }
     pf("\n");
 }
 }


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 ll int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 ll int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
 if(divide/second==2&&divide==total)
 {
     pf("%d\n",second);
     continue;
 }
     if(second>=total)
     {
         pf("-1\n");
         continue;
     }
     maxy=max(second,divide);
     for(i=maxy+1;i<=total;++i)
     {   //star;
         if(i==total&&i%divide==0)
         {
             pf("%lld\n",i-second);
            return 0;
            // continue;
         }
         else if(i%divide==0)
         {
             hand=i-second;
             flag=1;
             break;
         }
     }
     if(flag==0)
     {
         pf("-1\n");continue;
     }
     //debug(hand);
     for(i=hand;i+second<=total;i+=divide)
     { //star;star;
         pf("%lld ",i);
     }
     pf("\n");
 }
 }


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 ll int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 ll int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
 if(divide/second==2&&divide==total)
 {
     pf("%d\n",second);
     continue;
 }
     if(second>=total)
     {
         pf("-1\n");
         continue;
     }
    // maxy=max(second,divide);
     //if(maxy==second) maxy++;
k=1;
     for(i=divide;i<=total;i=divide*k)
     {
       if(i>second)
       { //star;
           hand=i-second;
           flag=1;
           break;
       }
         k++;
     }
     //debug(flag);
     if(flag==0)
     {
         pf("-1\n");continue;
     }
     //debug(hand);
     for(i=hand;i+second<=total;i+=divide)
     { //star;star;
         pf("%lld ",i);
     }
     pf("\n");
 }
 }


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 ll int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 ll int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
 if(divide/second==2&&divide==total)
 {
     pf("%d\n",second);
     continue;
 }
     if(second>=total)
     {
         pf("-1\n");
         continue;
     }
     maxy=(second,divide);
     for(i=maxy+1;i<=total;++i)
     {   //star;
         if(i==total&&i%divide==0)
         {
             pf("%lld\n",i-second);
            return 0;
            // continue;
         }
         else if(i%divide==0)
         {
             hand=i-second;
             flag=1;
             break;
         }
     }
     if(flag==0)
     {
         pf("-1\n");continue;
     }
     for(i=hand;i+second<=total;i+=divide)
     { //star;star;
         pf("%lld ",i);
     }
     pf("\n");
 }
 }


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 ll int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 ll int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
 if(divide/second==2&&divide==total)
 {
     pf("%d\n",second);
     continue;
 }
     if(second>=total)
     {
         pf("-1\n");
         continue;
     }
    // maxy=max(second,divide);
     //if(maxy==second) maxy++;
k=1;
     for(i=divide;i<=total;i*=k)
     {
       if(i>=second)
       {
           hand=i-second;
           flag=1;
           break;
       }
         k++;
     }
     if(flag==0)
     {
         pf("-1\n");continue;
     }
     //debug(hand);
     for(i=hand;i+second<=total;i+=divide)
     { //star;star;
         pf("%lld ",i);
     }
     pf("\n");
 }
 }


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
     if(second>=total)
     {
         pf("-1\n");
         continue;
     }
     for(i=second+1;i<=total;++i)
     {
         if(i==total&&i%divide==0)
         {
             pf("%d\n",i);
             return 0;
         }
         else if(i%divide==0)
         {
             hand=i-second;
             flag=1;
             break;
         }
     }
     if(flag==0)
     {
         pf("-1\n");return 0;
     }
     for(i=hand;i+second<=total;i+=divide)
     {
         pf("%d ",i);
     }
     pf("\n");
 }
 }


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define sc scanf
#define pf printf
#define pi 3.141592653589793
#define MP make_pair
#define PB push_back
#define debug(x) cout<<x<<endl;
#define debug2(x,y) cout<<x<<"  "<<y<<endl
#define star cout<<"*"<<endl;
#define    getI(a)           scanf("%d", &a)
#define    getII(a,b)       scanf("%d %d", &a,&b);
#define    getL(a)         scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define N 10001
#define F first
#define S second
//int fx[ ]={0,0,+1,-1}; int fy[ ]={+1,-1,0,0};
//template ends here
//int arr[1000009],brr[1000009];
int main()
{
//freopen("input.txt","r",stdin);
//int sqrtN = int( sqrt( (double) n) );
 ios_base::sync_with_stdio(0); cin.tie(0);
 ll int a,b,cnt=0,sum=0,i,j,hand,flag=0,c,n,m,k,t,res,maxy=0,miny=12345678910;
 ll int second,divide,total,rest;
 while(cin>>second>>divide>>total)
 { flag=0;
     if(second>=total)
     {
         pf("-1\n");
         continue;
     }
     for(i=second+1;i<=total;++i)
     {
         if(i==total&&i%divide==0)
         {
             pf("%lld\n",i);
             return 0;
         }
         else if(i%divide==0)
         {
             hand=i-second;
             flag=1;
             break;
         }
     }
     if(flag==0)
     {
         pf("-1\n");return 0;
     }
     for(i=hand;i+second<=total;i+=divide)
     {
         pf("%lld ",i);
     }
     pf("\n");
 }
 }


#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

		long long y,k,i,n,v[100000000],x=0;

int main()
{

	  cin>>y>>k>>n;
	  if(k>y) i=k-y;
	  else i=1;
		for(; i+y<=n  ; ){

				if((i+y) % k==0 && i+y>=k){
					v[x++]=i;
					i=i+k;
					//continue;
				}

		}
		for(long long i=0;i<x;i++){
			cout<<v[i]<<" ";
		}
		if(x==0)
		cout<<-1<<" ";
		return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
		int y,k,n,v[100],x=0;
		cin>>y>>k>>n;
		for(int i=1;i+y<=n;i++){

			if((i+y)%k==0 &&(i+y)<=n)
				v[x++]=i;
		}
		for(int i=0;i<x;i++){
			cout<<v[i]<<" ";
		}
		if(x==0)
		cout<<-1<<" ";
		return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cmath>
#include <algorithm>
#include<set>
#include<queue>
#include <typeinfo>
using namespace std;
#define ll long long

int main()
{
    int y,k,n ;
    cin>>y>>k>>n ;
    int c = y%k ;
    int a = k-c ;
    bool b = false ;
    int i = 0 ;
    while((i*k+a)<=(n-y))
    {
        b=true;
        cout<<(i*k+a)<<" ";
        i++;
    }
    if (!b)cout<<-1<<endl ;
    return 0 ;
}


#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
		int y,k,n,v[100],x=0;
		cin>>y>>k>>n;
		for(int i=1;i<=n;i++){

			if((i+y)%k==0 &&(i+y)<=n)
				v[x++]=i;
		}
		for(int i=0;i<x;i++){
			cout<<v[i]<<" ";
		}
		if(x==0)
		cout<<-1<<" ";
		return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

		long long y,k,i,n/*,v[100000000]*/,x=0;

int main()
{

	  cin>>y>>k>>n;
	  //vector<int> v(n);

	    if(k>y){
			i=k-y;
		for(long long i=0;i+y<=n;i++){
			cout<<i<<" ";
			i=i+k;
		}
	   }

		if(k<y){

			for(int i=1;i+y<=n;i++){

				if((i+y)%k==0 &&(i+y)<=n)
					cout<<i<<" ";
			 }

		}
		else
			cout<<-1<<" ";
		return 0;
}


	#include <iostream>
	#include <cstdio>
	#include <string>
	#include <cmath>
	#include <iomanip>
	#include <vector>
	#include <set>
	#include <algorithm>
	using namespace std;
			long long y,k,i,n/*,v[100000000]*/,x=0;
	int main()
	{
		  cin>>y>>k>>n;
			if(k>y){
				i=k-y;
			for(;i+y<=n;){
				cout<<i<<" ";x++;
				i=i+k;
			}if(x!=0)return 0;
		   }

			else if(k<y){

				for(int i=1;i+y<=n;i++){

					if((i+y)%k==0 &&(i+y)<=n){
						cout<<i<<" ";x++;}
				 }

			}

			 if(x==0)
				cout<<-1<<" ";
			return 0;
	}