#include #include #include #define rep(i,a) for(int i=0;i<(a);++i) #define clr(a,v) memset((a),(v),sizeof(a)) const int MAX_N = 1000; int N, V[MAX_N]; int dp[MAX_N][2]; int rec( int i, bool fl ) { if( i == N ) return 0; int &ret = dp[i][fl]; if( ~ret ) return ret; if( !fl ) return ret = std::max( rec( i+1, false ), rec( i+1, true )+V[i] ); else return ret = rec( i+1, false ); } int main() { clr( dp, -1 ); scanf( "%d", &N ); rep( i, N ) scanf( "%d", V+i ); printf( "%d\n", rec( 0, 0 ) ); return 0; }