import java.io.*; import java.util.*; import java.math.*; class Main { public static void out (Object o) { System.out.println(o); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] v = new int[n]; int[] d = new int[n]; String[] s = br.readLine().split(" "); for (int i = 0; i < n; i++) v[i] = Integer.parseInt(s[i]); d[0] = v[0]; d[1] = Math.max(v[0] , v[1]); for (int i = 2; i < n; i++) d[i] = Math.max(d[i - 1] , d[i - 2] + v[i]); out(d[n - 1]); } }