using System; using System.Collections.Generic; namespace sushi { class MainClass { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] A = new int[N]; string[] row = Console.ReadLine().Split(); for (int i = 0; i < N; i++) { A[i] = int.Parse(row[i]); } if (N==1){ Console.WriteLine(A[0]); return; } if (N == 2) { Console.WriteLine(Math.Max(A[0],A[1])); return; } int[] P = new int[N]; P[0] = A[0]; P[1] = A[1]; P[2] = P[0] + A[2]; for (int i = 3; i < N; i++) { P[i] = Math.Max(P[i - 2] + A[i], P[i - 3] + A[i]); } if (P[N-2]>P[N-1]){ Console.WriteLine(P[N - 2]); }else{ Console.WriteLine(P[N - 1]); } } } }