using System; using System.Linq; namespace _45 { 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(x.Max()); 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] = dp[0] + x[2]; for (int i = 3; i < n; i++) { dp[i] = Math.Max(dp[i - 2],dp[i - 3]) + x[i]; } Console.WriteLine(dp.Max()); } } } }