#include <iostream>
#include <cstring>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n], opt[n+2];
memset(opt, 0, sizeof(opt));
for(int i = 0; i < n; i++)
cin >> arr[i];
for(int i = n-1; i >= 0; i--)
opt[i] = arr[i] + max(opt[i+2], opt[i+1]);
cout << max(opt[0], opt[1]) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCBuOwoJY2luID4+IG47CglpbnQgYXJyW25dLCBvcHRbbisyXTsKCW1lbXNldChvcHQsIDAsIHNpemVvZihvcHQpKTsKCQoJZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykKCQljaW4gPj4gYXJyW2ldOwoJCQoJZm9yKGludCBpID0gbi0xOyBpID49IDA7IGktLSkKCQlvcHRbaV0gPSBhcnJbaV0gKyBtYXgob3B0W2krMl0sIG9wdFtpKzFdKTsKCQoJY291dCA8PCBtYXgob3B0WzBdLCBvcHRbMV0pIDw8IGVuZGw7CglyZXR1cm4gMDsKfQ==