#include using namespace std; const long long INF = 1000000000000000000; vector> matrix_multiplication(vector> A, vector> B){ int N = A.size(); vector> C(N, vector(N, INF)); for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ for (int k = 0; k < N; k++){ C[i][k] = min(C[i][k], A[i][j] + B[j][k]); } } } return C; } vector> matrix_exponentiation(vector> A, int M){ int N = A.size(); vector> ans(N, vector(N, INF)); for (int i = 0; i < N; i++){ ans[i][i] = 0; } while (M > 0){ if (M % 2 == 1){ ans = matrix_multiplication(ans, A); } A = matrix_multiplication(A, A); M /= 2; } return ans; } int main(){ int N, V; cin >> N >> V; vector C(N); for (int i = 0; i < N; i++){ cin >> C[i]; } vector S(N + 1); S[0] = 0; for (int i = 0; i < N; i++){ S[i + 1] = S[i] + C[i]; } V = max(V, N) - N; vector> M(N, vector(N, INF)); for (int i = 0; i < N - 1; i++){ M[i][i + 1] = 0; } for (int i = 0; i < N; i++){ M[i][0] = S[i + 1]; } M = matrix_exponentiation(M, V); cout << M[0][0] + S[N] << endl; }