import java.util.*; class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] v = new int[n+1]; int[] dou = new int[n+1]; Arrays.fill(dou,-1); for(int i = 1; i <= n; i++){ v[i] = sc.nextInt(); } class Inner{ public int umai(int mai){ if(dou[mai] == -1){ if(mai >= 3){ dou[mai] = Math.max(umai(mai-2) + v[mai],umai(mai-3) + v[mai]); return dou[mai]; }else if(mai >= 2){ dou[mai] = umai(mai-2) + v[mai]; return dou[mai]; }else{ dou[mai] = v[mai]; return dou[mai]; } }else{ return dou[mai]; } } } Inner in = new Inner(); int answer = Math.max(in.umai(n),in.umai(n-1)); System.out.print(answer); } }