#include using namespace std; typedef long long ll; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) int dp[1010]; int main(){ int N; cin >> N; REP(i,N){ int K; cin >> K; dp[i+1] = max(dp[i+1], (i-1>=0?dp[i-1]:0)+K); dp[i+1] = max(dp[i+1], dp[i]); } cout << dp[N] << endl; return 0; }