#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define INF (1 << 30) #define INFLL (1LL << 60) int sushi[1010] = {}; int n; int memo[1010]; int dp(int now){ if(now >= n) return 0; if(memo[now] != INF) return memo[now]; int a,b; a = dp(now + 1); b = dp(now + 2) + sushi[now]; return memo[now] = max(a,b); } int main() { for(int i = 0;i < 1010;i++){ memo[i] = INF; } cin >> n; for(int i = 0;i < n;i++){ cin >> sushi[i]; } cout << dp(0) << endl; return 0; }