#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <complex>
using namespace std;
const double pi = 3.14159265358979323846264338;
long long easy_factor(long long n){
  if (n == 1){
    return 1;
  }
  else{
    long long p = 2;
    long long f = 2;
    while (n % p != 0){
      p += 1;
      if (n % p == 0){
        f = p;
        break;
      }
      if (p * p > n){
        f = n;
        break;
      }
    }
    return f;
  }
}

template <typename T>
T vecout(T A){
  for (int i=0;i<A.size();i++){
    cout << A.at(i) << endl;
  }
}

vector<complex<long double>> simply_fft(vector<complex<long double>> f, long long n){
  if (n == 1){
    return f;
  }
  else{
    long long dn = n / 2;
    vector<complex<long double>> fe(dn);
    vector<complex<long double>> fo(dn);
    for (long long j=0;j<dn;j++){
      fe.at(j) = f.at(2*j+0);
      fo.at(j) = f.at(2*j+1);
    }
    vector<complex<long double>> tmp0 = simply_fft(fe, dn);
    vector<complex<long double>> tmp1 = simply_fft(fo, dn);
    complex<long double> grow = 1.0 + 0.0i;
    complex<long double> seed = cos((2.0*pi)/n) - 1i*sin((2.0*pi)/n);
    complex<long double> right = 0;
    for (long long i=0;i<dn;i++){
      right = tmp1.at(i) * grow;
      f.at(i) = tmp0.at(i) + right;
      f.at(i+dn) = tmp0.at(i) - right;
      grow *= seed;
    }
    return f;
  }
}

vector<complex<long double>> simply_ifft(vector<complex<long double>> f, long long n){
  if (n == 1){
    return f;
  }
  else{
    long long dn = n / 2;
    vector<complex<long double>> fe(dn);
    vector<complex<long double>> fo(dn);
    for (long long j=0;j<dn;j++){
      fe.at(j) = f.at(2*j+0);
      fo.at(j) = f.at(2*j+1);
    }
    vector<complex<long double>> tmp0 = simply_ifft(fe, dn);
    vector<complex<long double>> tmp1 = simply_ifft(fo, dn);
    complex<long double> grow = 1.0 + 0.0i;
    complex<long double> seed = cos((2.0*pi)/n) + 1i*sin((2.0*pi)/n);
    complex<long double> right = 0;
    for (long long i=0;i<dn;i++){
      right = tmp1.at(i) * grow;
      f.at(i) = tmp0.at(i) + right;
      f.at(i+dn) = tmp0.at(i) - right;
      grow *= seed;
    }
    return f;
  }
}
vector<long long> vecmachine(){
  vector<long long> A(100000);
  for (int i=0;i<100000;i++){
    A.at(i) = 100000;
  }
  return A;
}
long long powlimit(long long x){
  long long y = 1;
  while (y < x){
    y *= 2;
  }
  return y;
}

// ------------------------------------------

int main(){
  long long N, M;
  cin >> N >> M;
  long long m = 0;
  vector<long long> A = vecmachine();
  for (int i=0;i<N;i++){
    //cin >> A.at(i);
    if (m < A.at(i)){
      m = A.at(i);
    }
  }
  long long pl = powlimit(2*m+2);
  vector<complex<long double>> X(pl, 0);
  for (int i=0;i<N;i++){
    X.at(A.at(i)) += 1.0;
  }
  vector<complex<long double>> F = simply_fft(X, pl);
  vector<complex<long double>> Y(pl, 0);
  for (int i=0;i<pl;i++){
    Y.at(i) = F.at(i) * F.at(i);
  }
  vector<complex<long double>> Z = simply_ifft(Y, pl);
  vector<long long> sol(pl, 0);
  for (long long i=0;i<pl;i++){
    sol.at(i) = floor(0.5+real(Z.at(i))/pl);
  }
  long long S = 0, i = pl - 1, pat = 0;
  while (pat < M){
    if (pat + sol.at(i) > M){
      S += (M - pat) * i;
      pat = M;
    }
    else{
      S += sol.at(i) * i;
      pat += sol.at(i);
    }
    i -= 1;
    if (i < 0){
      break;
    }
  }
  cout << S << endl;
}

### FIXED CODE ###

# ----------- gcd ----------- #
def gcd(x, y):
    k, l = x, y
    if y < 0:
        k, l = -k, -l
    while l:
        k, l = l, k % l
    return k
def extgcd(a, b, c):
    if b == 0:
        return c // a, 0
    if b < 0:
        a, b, c = -a, -b, -c
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
        x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
        k, l = l, k % l
    return c * x, c * y

# --------- IsPrime --------- #
def IsPrime(n):
    if n == 1:
        return False
    p = 2
    while p * p <= n:
        if n % p == 0:
            return False
        p += 1
    return True

# --- fraction calculator --- #
def fracsum(f1, f2, sign = 1):
    fs = [f1[0]*f2[1]+sign*f1[1]*f2[0], f1[1]*f2[1]]
    g = gcd(fs[0], fs[1])
    fs[0] //= g
    fs[1] //= g
    return fs
def fracprod(f1, f2):
    fs = [f1[0]*f2[0], f1[1]*f2[1]]
    g = gcd(fs[0], fs[1])
    fs[0] //= g
    fs[1] //= g
    return fs

# ------ factorization ------ #
def factorization(n):
    D = {}
    a = n
    p = 2
    while a != 1:
        cnt = 0
        while a % p == 0:
            cnt += 1
            a //= p
        if cnt != 0:
            D[p] = cnt
        p += 1
        if p * p > n and a != 1:
            D[a] = 1
            break
    return D
# --------------fact. calculator-------------- #
mod = 0 # <-- input modulo
maxf = 0           # <-- input factional limitation

def doubling(n, m, modulo=0):
    y = 1
    base = n
    tmp = m
    while tmp:
        if tmp % 2 == 1:
            y *= base
            if modulo > 0:
                y %= modulo
        base *= base
        if modulo > 0:
            base %= modulo
        tmp //= 2
    return y
def Vanilla(D):
    F = [1]
    for i in D:
        mL = F[:]
        dp = i
        for j in range(D[i]):
            for k in mL:
                F.append(dp*k)
            dp *= i
    return F
def bic(n):
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    return cnt

def inved(a, modulo=5):
    x, y, u, v, k, l = 1, 0, 0, 1, a, modulo
    while l != 0:
        x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
        k, l = l, k % l
    return x % modulo
"""D = {i: [] for i in range(27, 33)}
for i in range(27, 33):
    j = 1
    bas = 2**i
    while len(D[i]) < 5:
        if IsPrime(j*bas+1):
            D[i].append(j*bas+1)
        j += 2
print(D)"""
#mod = 40961
#mod = 998244353, primod = 50475, invmod = 305218526
mod = [2013265921, 2281701377, 3892314113] # 998244353 = 2^23 * (odd number)
primod = [137, 551, 499]
"""for k in range(3):
    S = factorization(mod[k] - 1)
    S = {2: S[2]}
    LL = Vanilla(S)
    print(LL)
    LL.sort(reverse=True)
    for i in range(350, 700):
        flg = (doubling(i, doubling(2, S[2]), mod[k]) == 1)
        for j in range(1, len(LL)):
            flg *= (doubling(i, LL[j], mod[k]) != 1)
        if flg:
            print(mod[k], i)
    print()"""
def powlimit(n):
    y = 1
    cnt = 0
    while y < n:
        y *= 2
        cnt += 1
    return y, cnt

N, M = map(int, input().split())
A = list(map(int, input().split()))
#A = [1 for i in range(N)]
mm = max(A)
F = [0 for _ in range(mm+1)]
for i in range(N):
    F[A[i]] += 1
"""N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
F = [0] + [AB[i][0] for i in range(N)]
G = [0] + [AB[i][1] for i in range(N)]"""
pl, c = powlimit(2*mm+2)
#pl, c = powlimit(2*N+2)
F = F[:] + [0]*(pl-mm-1)
prim = [[doubling(primod[j], doubling(2, 27-i), mod[j]) for i in range(27)] for j in range(2)]
invp = [[inved(prim[j][i], mod[j]) for i in range(27)] for j in range(2)]
#print(prim)
#print(invp)
def NTT(f, n, cn, num, inverse=False):
    if n == 1:
        return f
    if n == 2:
        return [(f[0]+f[1])%mod[num], (f[0]-f[1])%mod[num]]
    dn = n // 2
    fe = [f[2*i+0] for i in range(dn)]
    fo = [f[2*i+1] for i in range(dn)]
    fe = NTT(fe, dn, cn-1, num, inverse)
    fo = NTT(fo, dn, cn-1, num, inverse)
    seed = inverse * prim[num][cn] + (1 - inverse) * invp[num][cn]
    grow = 1
    xf = [0 for _ in range(n)]
    for i in range(dn):
        right = fo[i] * grow % mod[num]
        xf[i+0*dn] = (fe[i] + right) % mod[num]
        xf[i+1*dn] = (fe[i] - right) % mod[num]
        grow *= seed
        grow %= mod[num]
    return xf

X = [NTT(F, pl, c, j) for j in range(2)]
#Y = NTT(G, pl, c)
#print(X)
#print(Y)
Z = [[X[j][i]*X[j][i]%mod[j] for i in range(pl)] for j in range(2)]
for j in range(2):
    Z[j] = NTT(Z[j], pl, c, j, 1)
#print(NTT(Z, pl, c, 1))
W = [0 for _ in range(2*mm+1)]
for j in range(2):
    ipl = inved(pl, mod[j])
    for i in range(pl):
        Z[j][i] *= ipl
        Z[j][i] %= mod[j]
for i in range(2*mm+1):
    k1, k2 = extgcd(mod[0], -mod[1], Z[1][i] - Z[0][i])
    W[i] = (mod[0]*k1+Z[0][i]) % (mod[0]*mod[1])
#print(W)
S = 2*max(A)
hp = 0
ccnt = 0
while ccnt < M:
    if ccnt + W[S] < M:
        ccnt += W[S]
        hp += S * W[S]
    else:
        hp += S * (M - ccnt)
        ccnt += M - ccnt
    S -= 1
print(hp)
#for i in range(1, max(A)+1):
#    print(Z[i]*ipl%mod)