import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class No45 { public static void main(String[] args) throws IOException { String[] read = readStr(); int N = Integer.parseInt(read[0]) , i = 0; String[] V = read[1].split(" "); int[] Vsum = new int[N]; Vsum[0] = Integer.parseInt(V[0]); if(N > 1) { Vsum[1] = Math.max(Integer.parseInt(V[1]), Vsum[0]); } if(N > 2) { for(i = 2;i < N;i++) { Vsum[i] = Math.max(Vsum[i-2] + Integer.parseInt(V[i]), Vsum[i-1]); } } System.out.println(Vsum[N-1]); } public static String[] readStr() throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList list = new ArrayList<>(); do { list.add(br.readLine()); }while(br.ready()); br.close(); String[] text = new String[list.size()]; list.toArray(text); return text; } }