using System; namespace ConsoleApp32 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] row = Console.ReadLine().Split(); int[] V = new int[N]; for (int i = 0; i < N; i++) { V[i] = int.Parse(row[i]); } if (N == 1) { Console.WriteLine(V[0]); } else if (N == 2) { Console.WriteLine(Math.Max(V[0], V[1])); } else { int[] taste = new int[N]; taste[0] = V[0]; taste[1] = V[1]; taste[2] = V[0] + V[2]; for (int i = 3; i < N; i++) { taste[i] = Math.Max(taste[i - 3] + V[i], taste[i - 2] + V[i]); } Console.WriteLine(Math.Max(taste[N - 2], taste[N - 1])); } } } }