import java.io.*; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main (String[] args) throws IOException { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int V[]= new int [N+1]; int f[] = new int [N+1]; for (int i = 1 ; i <= N ; i++){ V[i] = sc.nextInt(); } if (N == 1){ System.out.println(V[1]); } else if (N==2){ System.out.println(Math.max(V[1],V[2])); } else { f[1] = V[1]; f[2] = Math.max(V[1],V[2]); for (int i = 3 ; i <= N ; i++){ f[i] = Math.max(f[i-2] + V[i],f[i-1]); } System.out.println(f[N]); } } }