#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int mod=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


struct cmplx{
    double x, y;
    cmplx() : x(0), y(0) {}
    cmplx(double x, double y) : x(x), y(y) {}
    inline cmplx operator+(const cmplx &r) const { return cmplx(x + r.x, y + r.y); }
    inline cmplx operator-(const cmplx &r) const { return cmplx(x - r.x, y - r.y); }
    inline cmplx operator*(const cmplx &r) const { return cmplx(x * r.x - y * r.y, x * r.y + y * r.x); }
    inline cmplx conj() const { return cmplx(x, -y); }
};
int fftbase = 1;
vector<cmplx> fftrts = {{0, 0}, {1, 0}};
vector<int> fftrev = {0, 1};
void ensure_base(int nbase) {
    if (nbase <= fftbase) return;
    fftrev.resize(1 << nbase);
    fftrts.resize(1 << nbase);
    for (int i = 0; i < (1 << nbase); i++) {
        fftrev[i] = (fftrev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    while (fftbase < nbase) {
        double angle = M_PI * 2.0 / (1 << (fftbase + 1));
        for (int i = 1 << (fftbase - 1); i < (1 << fftbase); i++) {
            fftrts[i << 1] = fftrts[i];
            double angle_i = angle * (2 * i + 1 - (1 << fftbase));
            fftrts[(i << 1) + 1] = {cos(angle_i), sin(angle_i)};
        }
        ++fftbase;
    }
}
void fft(int n, vector<cmplx> &a) {
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = fftbase - zeros;
    for (int i = 0; i < n; i++) {
        if (i < (fftrev[i] >> shift)) {
            swap(a[i], a[fftrev[i] >> shift]);
        }
    }
    for (int k = 1; k < n; k <<= 1) {
        for (int i = 0; i < n; i += 2 * k) {
            for (int j = 0; j < k; j++) {
                cmplx z = a[i + j + k] * fftrts[j + k];
                a[i + j + k] = a[i + j] - z;
                a[i + j] = a[i + j] + z;
            }
        }
    }
}
template<typename T>
std::vector<cmplx> conv_cmplx(const std::vector<T> &a, const std::vector<T> &b)
{
    int N = 1;
    while (N < (int)a.size() + (int)b.size()) N *= 2;
    std::vector<cmplx> a_(N), b_(N);
    for (int i = 0; i < (int)a.size(); i++) a_[i] = {double(a[i]), 0};
    fft(N, a_);
    if (a == b) b_ = a_;
    else {
        for (int i = 0; i < (int)b.size(); i++) b_[i] = {double(b[i]), 0};
        fft(N, b_);
    }
    for (int i = 0; i < N; i++) a_[i] = a_[i] * b_[i];
    reverse(a_.begin() + 1, a_.end());
    fft(N, a_);
    for (int i = 0; i < N; i++) a_[i].x /= N, a_[i].y /= N;
    return a_;
}
template<typename T>
std::vector<long long int> fftconv(const std::vector<T> &a, const std::vector<T> &b)
{
    std::vector<cmplx> ans = conv_cmplx(a, b);
    std::vector<long long int> ret(ans.size());
    for (int i = 0; i < (int)ans.size(); i++) ret[i] = llround(ans[i].x);
    return ret;
}


signed main(void)
{
	IOS;
	ll n,m; cin>>n>>m;
	vi a(n);
	for(ll i = 0; i < n; i++)
		cin>>a[i];
	vi poly1(100010);
	for(ll i = 0; i < n; i++)
		poly1[a[i]]++;
	vi poly2=poly1;
	vi ans = fftconv(poly1,poly2);
	// vi ans = FFT::mod_multiply(poly1,poly2,MOD,true);
	// cout<<sz(ans)<<endl;
	ll cnt=0;
	ll sum=0;
	for(ll i=sz(ans)-1; i>=0; i--) {
		if(cnt+ans[i] >= m) {
			sum += (m-cnt)*i;
			break;
		} else {
			sum += ans[i]*i;
			cnt += ans[i];
		}
	}
	cout<<sum<<endl;
	// time();
	return 0;
}

Measured memory_bytes: 16000