#include #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define SZ(n) (int)(n).size() #define ALL(n) (n).begin(), (n).end() #define MOD 1000003 #define INF 100000000 using namespace std; typedef long long LL; typedef vector VI; typedef pair PI; int main() { int n; cin >> n; int v[1010] = {}; REP(i, n) cin >> v[i]; LL s[1010] = {}; REP(i, n) s[i + 1] = v[i]; FOR(i, 3, n + 1) { if (s[i - 2] >= s[i - 3]) s[i] += s[i - 2]; else s[i] += s[i - 3]; } cout << max(s[n], s[n - 1]) << endl; return 0; }