import java.util.*; public class Main { static int[] values; static int[] dp; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } dp = new int[n]; System.out.println(dfw(n - 1)); } static int dfw(int idx) { if (idx < 0) { return 0; } if (dp[idx] == 0) { dp[idx] = Math.max(dfw(idx - 1), dfw(idx - 2) + values[idx]); } return dp[idx]; } }