#include<stdio.h> int main (void){ int N,A[1000],ans[1000],i; scanf("%d",&N); for(i=0;i<N;i++){ scanf("%d",&A[i]); } ans[1]=A[1]; if(N == 1){ printf("%d",A[0]); return 0; } if(N == 2){ if(A[0]<A[1]){ printf("%d",A[1]); return 0; }else{ printf("%d",A[0]); return 0; } } if(A[1]<A[0]+A[2]){ ans[2] = A[0]+A[2]; }else { ans[2] = A[1]; } if(N == 3){ printf("%d",ans[2]); return 0; } for(i=3;i<=N-1;i++){ if(ans[i-1] < ans[i-2]+A[i]){ ans[i] = ans[i-2]+A[i]; }else { ans[i] = ans[i-1]; } } printf("%d",ans[N-1]); }