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 (n == 1) Console.WriteLine(x[0]); else if (n == 2) Console.WriteLine(Math.Max(x[0],x[1])); else if (n == 3) Console.WriteLine(Math.Max(x[0] + x[2],x[1])); else { int[] dp = new int[n]; dp[0] = x[0]; dp[1] = x[1]; dp[2] = x[0] + x[2]; for (int i = 3; i < n; i++) { dp[i] = Math.Max(dp[i - 3],dp[i - 2]) + x[i]; } Console.WriteLine(dp[n - 1]); } } } }