#include<iostream>
int max(int a, int b);
int main() {
int n;
std::cin >> n;
int* points = new int[n];
int* tmp = new int[n];
for (int i = 0; i < n; i++) {
std::cin >> points[i];
tmp[i] = 0;
}
tmp[0] = points[0];
tmp[1] = points[1];
for (int i = 0; i < n - 1; i++) {
if (n - 1 - i >= 3) {
tmp[i + 2] = max(tmp[i + 2], tmp[i] + points[i + 2]);
tmp[i + 3] = max(tmp[i + 3], tmp[i] + points[i + 1] + points[i + 3]);
}
else if (n - 1 - i == 2)
tmp[i + 2] = max(tmp[i + 2], tmp[i] + points[i + 2]);
else
tmp[i + 1] = max(tmp[i + 1], tmp[i] + points[i + 1]);
}
std::cout << tmp[n - 1];
}
int max(int a, int b) {
if (a > b)
return a;
else
return b;
}