import std; void main() { int N; readf("%d\n", N); auto P = readln.chomp.split.to!(long[]); long res; foreach (i; 0 .. N) { long tmp = P[i] * (P[i] + 1) / 2 - 2 * (i + 1); if (res < tmp) { res = tmp; } } res.writeln; }