### BUGGY CODE ###

class FastModuloTransform():
    def __init__(self,omega=103,n=2**18,mod=2**18*5880+1):
        self.n = n
        self.omega = omega
        self.mod = mod
        self.rev = pow(omega,mod-2,mod)
    def _bit_reverse_(self,d):
        n = len(d)
        ns = n>>1
        nss = ns>>1
        ns1 = ns+1
        i = 0
        for j in range(0,ns,2):
            if j<i:
                d[i],d[j] = d[j],d[i]
                d[i+ns1],d[j+ns1] = d[j+ns1],d[i+ns1]
            d[i+1],d[j+ns] = d[j+ns],d[i+1]
            k = nss
            i ^= k
            while k > i:
                k >>= 1
                i ^= k
        return d
    def _fmt_(self,A,base):
        halfpow = pow(base,self.n//2,self.mod)
        n = self.n
        m = 1
        while n > 1:
            n >>= 1
            w = pow(base,n,self.mod)
            wk = 1
            for j in range(m):
                for i in range(j,self.n,2*m):
                    U = A[i]
                    V = (A[i+m]*wk)%self.mod
                    A[i] = (U+V)%self.mod
                    A[i+m] = (U+V*halfpow)%self.mod
                wk = (wk*w)%self.mod
            m <<= 1
        return A
    def fmt(self,f):
        A = f+[0]*(self.n-len(f))
        self._bit_reverse_(A)
        F = self._fmt_(A,self.omega)
        return F
    def ifmt(self,F):
        A = F+[0]*(self.n-len(F))
        self._bit_reverse_(A)
        nrev = pow(self.n,self.mod-2,self.mod)
        f = [(e*nrev)%self.mod for e in self._fmt_(A,self.rev)]
        return f
    def convolute(self,f,g):
        F = self.fmt(f)
        G = self.fmt(g)
        H = [(s*t)%self.mod for s,t in zip(F,G)]
        h = self.ifmt(H)
        return h

#MOD = 2**23*7*17+1 # 998244353

MOD = 2**37*15+1 # 2061584302081

N,M = map(int,input().split())
power = list(map(int,input().split()))
count = [0 for _ in range(200010)]

for p in power:
    count[p] += 1

ntt = FastModuloTransform(1710766,2**18,MOD)
convoluted = ntt.convolute(count,count)

shake = 0
ans = 0

for i in range(len(convoluted))[::-1]:
    if shake + convoluted[i] <= M:
        ans += i*convoluted[i]
        shake += convoluted[i]
    else:
        ans += i*(M-shake)
        break

print(ans)

### FIXED CODE ###

import cmath
pi = cmath.pi
exp = cmath.exp

import sys
readline = sys.stdin.readline
write = sys.stdout.write

def make_exp_t(N, base):
    exp_t = {0: 1}
    temp = N
    while temp:
        exp_t[temp] = exp(base / temp)
        temp >>= 1
    return exp_t

def fft_dfs(f, s, N, st, exp_t):
    if N==2:
        a = f[s]; b = f[s+st]
        return [a+b, a-b]
    N2 = N//2; st2 = st*2
    F0 = fft_dfs(f, s   , N2, st2, exp_t)
    F1 = fft_dfs(f, s+st, N2, st2, exp_t)
    w = exp_t[N]; wk = 1.0
    for k in range(N2):
        U = F0[k]; V = wk * F1[k]
        F0[k] = U + V
        F1[k] = U - V
        wk *= w
    F0.extend(F1)
    return F0

def fft(f, N):
    if N==1:
        return f
    return fft_dfs(f, 0, N, 1, fft_exp_t)

def ifft(F, N):
    if N==1:
        return F
    f = fft_dfs(F, 0, N, 1, ifft_exp_t)
    for i in range(N):
        f[i] /= N
    return f

N,M = map(int,input().split())

l = 10**5+1
L = 2**(2*l-1).bit_length()

power = list(map(int,input().split()))
count = [0.0 for _ in range(l)]

for p in power:
    count[p] += 1

fft_exp_t = make_exp_t(L, -2j*pi)
ifft_exp_t = make_exp_t(L, 2j*pi)

count.extend([0]*(L-l))

C = fft(count, L)

CC =[C[i]*C[i] for i in range(L)]

cc = ifft(CC,L)

shake = 0
ans = 0

for i in reversed(range(len(cc))):
    if shake+int(cc[i].real+0.5)<=M:
        ans += i*int(cc[i].real+0.5)
        shake += int(cc[i].real+0.5)
    else:
        ans += i*(M-shake)
        break
        
print(ans)