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