import java.io.BufferedReader;
import java.io.InputStreamReader;
class Solution {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int[] arr = new int[N+3];
int[] dp = new int[N+3];
for (int i = 0; i < N; i++) {
arr[i] = Integer.parseInt(br.readLine());
}
int temp = 0;
for(int i = 0 ; i <N; i ++) {
if(i <2) {
temp+=arr[i];
dp[i] =temp;
continue;
}else if(i == 2 ) {
dp[i] = Math.max(arr[2]+arr[0],Math.max(arr[0]+arr[1], arr[1]+arr[2]));
continue;
}
dp[i] = Math.max(dp[i-1], Math.max(dp[i-2]+arr[i], dp[i-3]+arr[i]+arr[i-1]));
}
int max = 0;
for(int i = 0 ; i < N ; i ++) {
max = max > dp[i] ? max :dp[i];
}
System.out.print(max);
}
}