#include <iostream>
#include <algorithm> // for sort, mainly
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <array>
#include <string>
#include <cstdio>
#include <iterator>
#include <unordered_set>
#include <cstdint> // for int64_t, int32_t, etc
#include <queue>
#include <stack>
#include <deque>
#include <numeric> // gcd, lcm
#include <fstream>
#include <bitset> // for bitset
#include <iomanip>
#include <cassert> // for set with custom ordering
#include <type_traits> // for set with custom ordering
#include <utility> // for swap, forward, etc
using namespace std;
#pragma GCC optimize("O2")
// #pragma GCC optimize("O1","O2","O3","Ofast","unroll-loops")
// #pragma GCC target("sse","sse2","sse3","sse4.1","sse4.2","avx","avx2","fma")
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
/*
notes:
int64_t
stoi(string s) -> string to int
to_string() -> int (or else) to string
vector declaration:
vector<ll> v(n, 0)
vector<vector<ll>> v(n, vector<ll>(n, 0));
{if statement} ? {truth value} : {false value}
#ifdef LOCAL
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
std::lcm(ll a, ll b), std::gcd(int a, int b)
cout << fixed << setprecision(n);
set with custom ordering
set<ll, decltype(&cmp)> qu(cmp);
*/
typedef int64_t ll;
void solve() {
ll n, k;
cin >> n >> k;
deque<ll> dq;
for(ll i = 0; i < n; i++) {
ll tmp;
cin >> tmp;
dq.push_back(tmp);
}
// leszimalunk egy "teljes" vegigmenest
// vagyis minden kartya megfordul a kezunkben legalabb egyszer
// es az azutani sorrend szerint keszitjuk el a prefix-et
// ami a vegere a kezunkben marad azt nem vesszuk figyelembe
ll handa = dq.front();
dq.pop_front();
ll handb = dq.front();
dq.pop_front();
if(n == 2) {
cout << k * min(handa, handb);
return;
}
ll cost = 0;
ll nc = min(n - 1, k);
//cerr << "\nnc=" << nc;
while(nc > 0) {
if(handa == 0) {
handa = dq.front();
dq.pop_front();
}
if(handb == 0) {
handb = dq.front();
dq.pop_front();
}
if(handa <= handb) {
cost += handa;
dq.push_back(handa);
handa = 0;
}
else{
cost += handb;
dq.push_back(handb);
handb = 0;
}
nc--;
}
//dq.push_back(min(handa, handb));
k -= (n - 1);
if(k == 0) {
cout << cost;
return;
}
n--;
vector<ll> v(n, 0);
vector<ll> pref(n, 0);
for(ll i = 0; i < n; i++) {
v[i] = dq.front();
dq.pop_front();
}
pref[0] = v[0];
for(ll i = 1; i < n; i++) {
pref[i] = pref[i-1] + v[i];
}
//cerr << "\nv=" << v;
//cerr << "\npref=" << pref;
//cerr << "\nk=" << k << "; n=" << n;
ll full = k / n;
ll plus = k % n;
cost += full * pref[n-1];
if(plus > 0) {
cost += pref[plus-1];
}
cout << cost;
}
int main()
{
std::ios_base::sync_with_stdio(false);
//cin.tie(nullptr);
//cout.tie(nullptr);
solve();
return 0;
}