import std.algorithm, std.array, std.container, std.range; import std.string, std.conv, std.math, std.random; import std.stdio, std.typecons; void main() { auto rd = readln.split.map!(to!int); auto n = rd[0]; auto k = rd[1]; auto si = readln.chomp.map!(to!string).map!(to!int).array; auto ti = new int[n]; ti[0] = 1; auto a = si[0]; foreach (i; 1..n) { if (a > 0) { ti[i] = ti[i - 1]; a -= 1; } else { ti[i] = ti[i - 1] + 1; } a += si[i]; } int r; if (k <= n) { r = ti[k - 1]; } else { r = ti.back; if (ti.back >= a) { r += (k / n - 1) * (ti.back - a); if (k % n != 0) r += max(ti[k % n - 1] - a, 0); } } writeln(r); }