#include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,b) for(i=a;i> n; rep(i,n) cin >> v[i]; if(n == 1) b = v[0]; else { a = v[0]; b = v[1]; if(v[0] > v[1]) b = v[0]; for(i=2;i a+v[i]) v[i] = b; else v[i] =a+v[i]; a = b; b = v[i]; } } cout << b << endl; return 0; }