using System; using System.Linq; class Program { public static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var vs = Console.ReadLine().Split(' ').Select(element => int.Parse(element)).ToArray(); var dp = new int[n+1]; dp[0] = 0; dp[1] = vs[0]; for (int i = 2; i <= n; i++) { dp[i] = Math.Max(dp[i - 2] + vs[i - 1], dp[i - 1]); } Console.WriteLine(dp[n]); } }