#include #include using namespace std; typedef long long ll; #define MAX_N 100 int N; ll T; ll C[MAX_N]; void input(istream& in) { in >> N >> T; for (int i = 0; i < N; i++) in >> C[i]; } ll resolve() { ll V[MAX_N]; for (int i = 0; i < N; i++) { V[i] = 1; } if (T > N) { T -= N; int min_index = 0; ll min_value = C[0]; for (int i = 1; i < N; i++) { if (C[i] < min_value) { min_index = i; min_value = C[i]; } } ll v = T / (min_index + 1); for (int i = 0; i <= min_index; i++) { V[i] += v; } T -= v * (min_index + 1); if (T > 0) { for (int i = 0; i < T; i++) { V[i]++; } } } ll cost = 0; for (int i = 0; i < N; i++) { cost += C[i] * V[i]; } return cost; } int main(int argc, char **argv) { input(cin); cout << resolve() << endl; return 0; }