#include using namespace std; typedef long long int ll; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int a[n+10], dp[n+10]; for (int i = 1; i <= n; i++) cin >> a[i]; dp[1] = a[1]; dp[2] = max(a[1], a[2]); for (int i = 3; i <= n; i++) { dp[i] = max(dp[i-1], dp[i-2] + a[i]); } cout << dp[n] << endl; return 0; }