import java.util.*; import java.awt.geom.*; import java.io.*; 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(); } int[] dp = new int[N+2]; for(int i = 0; i < N; i++) { dp[i+1] = Math.max(dp[i], dp[i+1]); dp[i+2] = Math.max(dp[i] + V[i], dp[i+2]); } dp[N+1] = Math.max(dp[N+1], dp[N]); System.out.println((dp[N+1])); } }