import java.util.Scanner; public class No45 { 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]; dp[0] = V[0]; if(N >= 2) { dp[1] = Math.max(dp[0],V[1]); } for(int i = 2;i < N;i++) { dp[i] = Math.max(dp[i-1],dp[i-2]+V[i]); } System.out.println(dp[N-1]); } }