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