import java.util.Scanner; class sushi2 { private static final int MAX_N = 1000; static int v[] = new int[MAX_N]; //sushiの価値 public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 0; i < n; i++) { v[i] = sc.nextInt(); } sc.close(); int[] sum = {0,0};//{2個前までの合計,1個前までの合計} int b = 0; for (int i = 0 ; i < n ;i++) { b = Math.max(sum[0] + v[i] , sum[1]); sum[0] = sum[1]; sum[1] = b; } System.out.println(Math.max(sum[0], sum[1])); } }