// https://yukicoder.me/problems/no/45 #include using namespace std; int dp[1005]; int main() { int n; cin >> n; vector v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } for (int i = 0; i < n; i++) { dp[i + 2] = max(dp[i + 2], dp[i] + v[i]); dp[i + 3] = max(dp[i + 3], dp[i] + v[i]); } cout << max({dp[n], dp[n + 1], dp[n + 2]}) << endl; return 0; }