import java.util.*; public class Main { 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(); } // dp[i]は最後の寿司が寿司iの場合の美味しさの最大値を表す int[] dp = new int[N]; // max[i] = max(0≦j≦i)dp[j] int[] max = new int[N]; dp[0] = v[0]; max[0] = dp[0]; if(N > 1) { dp[1] = v[1]; max[1] = Math.max(max[0], dp[1]); } for(int i = 2; i < N; i++) { dp[i] = v[i] + max[i - 2]; max[i] = Math.max(dp[i], max[i - 1]); } System.out.println(max[N - 1]); } }