using System; using System.Linq; namespace KaitenSushi { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] P = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); int R = MainProcess(N,P); Console.WriteLine(R); } private static int MainProcess(int N,int[] P) { int[] M = new int[N + 1]; M[0] = 0; M[1] = P[0]; for(int i = 2; i < N + 1; i++) { M[i] = Math.Max(M[i - 1], M[i - 2] + P[i - 1]); } return M[N]; } } }