#include #include #include #include #include #include #include #include #include #define int long long int #define rep(i, n) for(int i = 0; i < (n); ++i) using namespace std; typedef pair P; const int INF = 1e15; const int MOD = 1e9+7; signed main(){ int n; cin >> n; vector v(n+1); rep(i, n) cin >> v[i+1]; vector> dp(2, vector(n+1)); for(int i = 1; i <= n; i++){ dp[0][i] = max(dp[0][i-1], dp[1][i-1]); dp[1][i] = dp[0][i-1] + v[i]; } cout << max(dp[0][n], dp[1][n]) << endl; return 0; }