#include #include #include #define DN 1000005 #define MOD 666013 #define LL long long using namespace std; int n,v[3],bst[4][DN]; int main() { //freopen("input.txt","r",stdin); while(cin>>n){ cin>>v[0]>>v[1]>>v[2]; bst[3][2]=v[1]; bst[1][2]=v[0]; for(int i=3; i<=n+1; ++i) { for(int j=0; j<4; ++j) bst[j][i]=0; bst[3][i]=max(bst[3][i-1]+v[2],bst[2][i-1]+v[1]); bst[2][i]=max(bst[1][i-1] ,bst[0][i-1]); bst[1][i]=max(bst[2][i-1]+v[0],bst[3][i-1]+v[1]); bst[0][i]=max(bst[1][i-1], bst[0][i-1]); } cout<