#include #define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++) #define rrep(i,a,b) for(long long int i=(a);i<(b);i++) #define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--) #define all(v) (v).begin(), (v).end() #define pb(q) push_back(q) #define P pair #define Abs(a,b) max(a,b)-min(a,b) #define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;} #define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;} #define Cout(x) cout<<(x)<1){ // cmp=(cmp*hh)%MOD; //hh--; //} //return cmp; //} //long long int ruizyo(long long int aa, long long int bb){ // if(aa==0){ // return 1; //} //else if(aa%2==0){ // long long int tt=ruizyo(aa/2,bb); //return (tt*tt)%MOD; //} //else{ // return (ruizyo(aa-1,bb)*bb)%MOD; //} //}フェルマ-のア //while(x!=0){ //sum+=x%10; // x/=10; //} //各桁の和 //pair p[100000]; //P r[100000]; //cin >> tmp; //p[i]=make_pair(tmp,i); //cout << p[i].second+1 << endl;//ペアの右側つまりiを出力 //s.find(w[i])==string::npos //findの使い方 //for(int i=0;i>(10,vector(10,false));アを全部falseに long long int n,cnt=0,ans=0,a[1001],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,dp[1001]; int dy[]={1,0,-1,0}; int dx[]={0,1,0,-1}; string alph("abcdefghijklmnopqrstuvwxyz"),s,ww; bool fl=true; int main(void){ cin.tie(0); ios::sync_with_stdio(false); cin >> n; //dp[i]:i番目までで一番でっかいやつ rep(i,n){ cin>>a[i]; } dp[0]=a[0]; dp[1]=max(a[0],a[1]); rrep(i,2,n){ dp[i]+=max(dp[i-1],dp[i-2]+a[i]); // Cout(dp[i]); } Cout(dp[n-1]); return 0; }