#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define BET(a,b,c) ((a)<=(b)&&(b)<(c)) #define FOR(i,n) for(int i=0,i##_end=(int(n));i VI; typedef vector VVI; int main() { int n; cin>>n; VI V(n); FOR(i,n) cin>>V[i]; VI dp(n); FOR(i,n){ dp[i] = V[i]; if(i - 2 >= 0) dp[i] = max(dp[i], dp[i-2] + V[i]); if(i - 1 >= 0) dp[i] = max(dp[i], dp[i-1]); } cout<<*max_element(ALL(dp))<