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