import std.stdio, std.string, std.conv ,std.array,std.algorithm, std.range ,std.math; void main(){ auto buf = readln().strip().split().map!(to!int)(); immutable int N = buf[0]; immutable int V = buf[1]; auto C = readln().strip().split().map!(to!int)(); int now = 0; long ans = 0; long[100] cos; double[100] costd; cos[0] = C[0]; foreach(immutable int i; 1 .. N) cos[i] = cos[i-1] + C[i]; foreach(immutable int i; 0 .. N) costd[i] = cos[i].to!double / (i+1); ans += cos[N-1]; if(N >= V) { writeln(ans); return; } int num = V - N; void tc(int n) { double minc = double.max; int mincp; foreach(immutable int i; 0 .. n) { if(minc > costd[i]) { minc = costd[i]; mincp = i; } } ++ mincp; ans += (num / mincp) * cos[mincp-1]; //writeln("~", mincp, "(", cos[mincp-1], ")", "*", num / mincp, "=>", ans); num %= mincp; } tc(N); while(num != 0) { tc(num); } writeln(ans); }