import java.util.Arrays; import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int N = in.nextInt(); int[] v = new int[N + 1]; for(int i = 0; i < N; i++){ v[i] = in.nextInt(); } int[] y = new int[N + 1]; Arrays.fill(y, Integer.MAX_VALUE); y[0] = 0; y[1] = v[0]; for(int i = 2; i < v.length; i++){ y[i] = Math.max(y[i - 1], y[i - 2] + v[i - 1]); } System.out.println(y[N]); } }