import java.util.Scanner; public class No45 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); int[] v = new int[N]; int[] dp = new int[N]; for (int i = 0; i < N; i++) { v[i] = Integer.parseInt(sc.next()); } if(N == 1){ System.out.println(v[0]); return; }else if(N == 2){ if(v[0] > v[1]){ System.out.println(v[0]); }else{ System.out.println(v[1]); } return; }else if(N == 3){ if(v[0] + v[2] > v[1]){ System.out.println(v[0] + v[2]); }else{ System.out.println(v[1]); } return; } dp[0] = v[0]; dp[1] = v[1]; dp[2] = dp[0] + v[2]; for (int i = 3; i < N; i++) { if(dp[i-3] > dp[i-2]){ dp[i] = dp[i-3] + v[i]; }else{ dp[i] = dp[i-2] + v[i]; } } if(dp[N-1] > dp[N-2]){ System.out.println(dp[N-1]); }else{ System.out.println(dp[N-2]); } } }