using static System.Math; using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); var dp = new int[n]; dp[0] = a[0]; dp[1] = Max(a[0], a[1]); for (int i = 2; i < n; i++) dp[i] = Max(dp[i - 1], dp[i - 2] + a[i]); Console.WriteLine(dp[n - 1]); } }