import std.algorithm, std.array, std.container, std.range; import std.string, std.conv, std.math; import std.stdio, std.typecons; void main() { auto n = readln.chomp.to!int; auto vi = readln.split.map!(to!int); if (n == 1) { writeln(vi[0]); } else { auto dp = new long[n]; dp[0] = vi[0]; dp[1] = max(vi[0], vi[1]); foreach (i; 2..n) { dp[i] = max(dp[i - 2] + vi[i], dp[i - 1]); } writeln(dp[n - 1]); } }