#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i < (int)(n + 1); i++) using ll = long long; using P = pair; using Graph = vector>; int main(){ int n; cin >> n; vector v(n, 0); rep(i, n)cin >> v[i]; vector> dp(2, vector(n, 0)); dp[1][0] = v[0]; rep1(i, n-1){ dp[0][i] = max(dp[1][i-1], dp[0][i-1]); dp[1][i] = max(dp[1][i-1], dp[0][i-1]+v[i]); } cout << max(dp[0][n-1], dp[1][n-1]) << endl; }