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) { if (V[0] > V[1]) { Console.WriteLine(V[0]); } else { Console.WriteLine(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++) { if (taste[i - 3] + V[i] > taste[i - 2] + V[i]) { taste[i] = taste[i - 3] + V[i]; } else { taste[i] = taste[i - 2] + V[i]; } } if (taste[N - 2] > taste[N - 1]) { Console.WriteLine(taste[N - 2]); } else { Console.WriteLine(taste[N - 1]); } } } } }