#include #include #define int long long using namespace std; int n, v; int c[100]; signed main() { int i, num; int sumC = 0; cin >> n >> v; for (i = 0; i < n; i++) cin >> c[i]; for (i = 0; i < n; i++) sumC += c[i]; v -= n; if (v <= 0) { cout << sumC << endl; return 0; } int ans = 2e+18; for (num = 1; num <= n; num++) { int syo = v / num; int mod = v % num; int cst = 0; for (i = 0; i < mod; i++) { cst += (syo + 1) * c[i]; } for (i = mod; i < num; i++) { cst += syo * c[i]; } ans = min(ans, cst); } ans += sumC; cout << ans << endl; return 0; }