import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int prevPrev = sc.nextInt(); if(n == 1) { System.out.println(prevPrev); return; } int prev = Math.max(prevPrev, sc.nextInt()); int res = Math.max(prevPrev, prev); for(int i = 3; i <= n; i++) { int num = sc.nextInt(); res = Math.max(num + prevPrev, prev); prevPrev = prev; prev = res; } System.out.println(res); } }