#include #include #include using namespace std; const long long INF = 1LL << 60; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { int n, v; cin >> n >> v; vector c(n); for (auto &ci: c) cin >> ci; v = max(0, v - n); vector acc(n + 1); for (int k = 0; k < n; k++) acc[k + 1] = acc[k] + c[k]; int opt = 1; for (int k = 2; k <= n; k++) if (acc[opt] * k > acc[k] * opt) opt = k; vector dp(n * n + 1, INF); dp[0] = 0; for (int k = 1; k <= n; k++) { for (int i = k; i <= n * n; i++) chmin(dp[i], dp[i - k] + acc[k]); } int m = max(0, (v - n * n + n) / opt); long long res = acc[opt] * m + dp[v - m * opt] + acc[n]; cout << res << endl; return 0; }