import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int []V = new int[N]; for(int i = 0; i < N; i++) { V[i] = scan.nextInt(); } scan.close(); if(N == 1) { System.out.println(V[0]); System.exit(0); } int []dp = new int[N]; Arrays.fill(dp, 0); dp[0] = V[0]; dp[1] = Math.max(V[0], V[1]); for(int i = 2; i < N; i++) { dp[i] = Math.max(dp[i - 1], dp[i - 2] + V[i]); } System.out.println(dp[N - 1]); } }