#include #include #include #include #include #include #include #define MAX_N 1000 int main(){ int* dp = (int*)malloc(MAX_N * sizeof(int)); int n; int* v =(int*)malloc(MAX_N * sizeof(int)); std::cin >> n; for(register int i = 0; i < n; i++){ std::cin >> v[i]; } for(register int i =0; i < n; i++){ if(i < 2) dp[i] = v[i]; else if(i == 2) dp[i] = v[i] + v[0]; else dp[i] = std::max(dp[i -2],dp[i -3]) + v[i]; } printf("%d\n",std::max(dp[n-1],dp[n-2])); }