using System; using System.Collections.Generic; using System.Linq; namespace Test { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray(); if (x.Length == 1) Console.WriteLine(x[0]); else if (x.Length == 2) Console.WriteLine(Math.Max(x[0],x[1])); else if (x.Length == 3) Console.WriteLine(Math.Max(x[0] + x[2],x[1])); else { int[] dp = new int[x.Length]; dp[0] = x[0]; dp[1] = x[1]; dp[2] = x[0] + x[2]; for (int i = 3; i < x.Length; i++) { dp[i] = Math.Max(dp[i - 3],dp[i - 2]) + x[i]; } Console.WriteLine(dp[x.Length - 1]); } } } }