using System; using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; namespace lecture { 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; } int[] P = new int[N]; P[0] = A[0]; P[1] = A[1]; for (int i = 0; i < N - 2; i++) { if(P[i+2] < P[i] + A[i+2]) { P[i + 2] = P[i] + A[i + 2]; } if (i + 3 < N) { if (P[i + 3] < P[i] + A[i + 3]) { P[i + 3] = P[i] + A[i + 3]; } } } // 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]); } } } }