#include #include #include #include using namespace std; int main(){ int n, v; cin >> n >> v; vector c(n); for (int i = 0; i < n; ++i) cin >> c[i]; partial_sum(c.begin(), c.end(), c.begin()); const int N = 300; vector dp(N + 10, 1e18); dp[0] = 0; for (int i = 0; i < n; ++i){ for (int j = 0; j < N - i; ++j){ dp[i + 1 + j] = min(dp[i + 1 + j], dp[j] + c[i]); } } for (int i = N; i >= 0; --i) dp[i] = min(dp[i], dp[i + 1]); long long base = c.back(); v = max(0, v - n); long long ans = 1e18; for (int i = 0; i < n; ++i){ ans = min(ans, v / (i + 1) * c[i] + dp[v % (i + 1)]); } cout << base+ans << endl; return 0; }