#include using namespace std; using LL = long long; using ULL = unsigned long long; int dp[1001][2]; int V[1001]; int main() { int N; cin >> N; for (int i = 1; i <= N; i++) cin >> V[i]; for (int i = 1; i <= N; i++) { dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]); dp[i][1] = dp[i - 1][0] + V[i]; } cout << max(dp[N][0], dp[N][1]) << endl; }