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