#include int sushi(int n, int v[]) { int ans = 0; if (n == 0) return 0; if (n == 1) return v[0]; if (n == 2) { if (v[0] >= v[1]) return v[0]; else return v[1]; } if (n == 3) { if (v[0]+v[2] > v[1]) return v[0] + v[2]; else return v[1]; } if (v[n-1]+v[n-3] > v[n-2]) return v[n-1]+v[n-3] + sushi(n-4, v); else return v[n-2] + sushi(n-3, v); } int main(void) { int n, i, v[1000]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &v[i]); } if (v[n - 1] >= v[n - 2]) printf("%d", v[n-1]+sushi(n-2, v)); else printf("%d", v[n-2]+sushi(n-3, v)); return 0; }