import java.util.Scanner; public class Main_yukicoder45 { 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]; int max = 0; for (int i = 0; i < n; i++) { dp[i] = v[i]; for (int j = Math.max(0, i - 3); j < i - 1; j++) { dp[i] = Math.max(dp[i], dp[j] + v[i]); } max = Math.max(max, dp[i]); } System.out.println(max); sc.close(); } }