import java.util.Scanner; public class Main { static boolean memo[]; static int ans, min; public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int n = sc.nextInt(); if (n > 1) { int[] dp = new int[n]; int[] v = new int[n]; for (int i = 0; i < n; i++) { v[i] = sc.nextInt(); } dp[0] = v[0]; dp[1] = Math.max(v[0], v[1]); for (int i = 2; i < n; i++) { dp[i] = Math.max(dp[i - 1], dp[i - 2] + v[i]); } int max = 0; for (int i = 0; i < n; i++) { max = Math.max(max, dp[i]); } System.out.println(max); } else { int v = sc.nextInt(); System.out.println(v); } } }