#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(int i=0;i> N >> A >> B >> C; ll t=N/10,D=0; for(i=0;i<=t;i++){ ll z=N-10*i; for(j=(3*z+4)/5;j<=2*z/3;j++){ D=max(D,(5*j-3*z)*A+(-3*j+2*z)*B+C*i); } } cout << D << endl; return 0; }