using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication6 { class Program { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] A = new int[N]; int[] B = 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; } B[0] = A[0]; B[1] = A[1]; for (int i = 0; i < N - 2; i++) { if (i + 2 < N && B[i+2] < B[i] + A[i+2]) { B[i + 2] = B[i] + A[i + 2]; } if (i + 3 < N && B[i] < B[i] + A[i + 3]) { B[i + 3] = B[i] + A[i + 3]; } } Console.WriteLine(B.Max()); } } }