#include using namespace std; const int MAXW = 10105; const int MAXN = 1005; int dp[MAXN][2]; int V[MAXN]; int main() { int N; scanf("%d", &N); for (int i = 0; i < N; ++i) scanf("%d", &V[i]); for (int i = 0; i < N; ++i) { dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + V[i]); dp[i + 1][0] = max(dp[i + 1][0], dp[i][1]); dp[i + 1][0] = max(dp[i + 1][0], dp[i][0]); } printf("%d\n", max(dp[N][0], dp[N][1])); return 0; }