#include #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) FOR(i,0,n) #define repr(i,n) for(int i=(n)-1;0<=i;--i) #define each(e,v) for(auto&& e:(v)) #define all(v) begin(v),end(v) #define DUMP(x) cerr<<#x<<": "<<(x)<; using vdouble = vector; using vstring = vector; using ll = long long; template void chmin(T& a, const T& b) { a = min(a, b); } template void chmax(T& a, const T& b) { a = max(a, b); } int main() { int n; cin >> n; vint v(n); rep(i, n) cin >> v[i]; int dp[1001]; dp[0] = 0; dp[1] = v[0]; FOR(i, 2, n+1) { dp[i] = max(dp[i-1], dp[i-2] + v[i-1]); } cout << dp[n] << endl; return 0; }