import std.stdio; import std.string, std.conv, std.array, std.algorithm; import std.uni, std.math, std.container; import core.bitop, std.datetime; void main(){ int N = readln.chomp.to!int; auto V = readln.split.to!(int[]); int[] dp = new int[](N + 1); dp[0] = 0, dp[1] = V[0]; foreach(i ; 2 .. N + 1){ dp[i] = max(dp[i - 1], dp[i - 2] + V[i - 1]); } writeln(dp[N]); }