#include using namespace std; typedef pair pii; typedef long long int ll; int n, ans; int a[1001]; int dp[1001][100000]; int f(int pos, int sum) { if (pos >= n) return sum; else if (dp[pos][sum]) return dp[pos][sum]; else return dp[pos][sum] = max(f(pos+1, sum), f(pos+2, sum+a[pos])); } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cout << f(0, 0) << endl; return 0; }