#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

//Source : https://cp-algorithms.com/algebra/fft.html#toc-tgt-6
using cd = complex<double>;
const double PI = acos(-1);
vector<int> rev;

void calc_rev(int n, int log_n){ //Call this before FFT
    rev.assign(n, 0);
    for(int i = 0; i < n; i++){
        rev[i] = 0;
        for(int j = 0; j < log_n; j++){
            if((i >> j) & 1)
                rev[i] |= (1 << (log_n - j - 1));
        }
    }
}

void fft(vector<cd>& a, bool invert){
    int n = a.size();
    //Ordering the array by reverse order of bits!
    for(int i = 0; i < n; i++){
        if(i < rev[i]) swap(a[i], a[rev[i]]);
    }

    for(int len = 2; len <= n; len <<= 1){
        double ang = 2 * PI / len * (invert ? -1 : 1);
        cd wlen(cos(ang), sin(ang));
        for(int i = 0; i < n; i += len){
            cd w(1);
            for(int j = 0; j < len/2; j++){
                cd u = a[i + j], v = a[i + j + len/2] * w;
                a[i + j] = u + v;
                a[i + j + len/2] = u - v;
                w *= wlen;
            }
        }
    }
    if(invert){
        for(cd &x : a)
            x /= n;
    }
}

//**Remember to change ll to other data types if needed.**
vector<ll> multiply(vector<ll>& a, vector<ll>& b){
    vector<cd> fa(all(a)), fb(all(b));
    int n = 1, log_n = 0;
    while(n < a.size() + b.size()) n <<= 1, log_n++;
    fa.resize(n);
    fb.resize(n);

    calc_rev(n, log_n);
    fft(fa, false);
    fft(fb, false);
    for(int i = 0; i < n; i++)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<ll> res(n);
    for(int i = 0; i < n; i++)
        res[i] = round(fa[i].real());
    return res;
}

vector<int> fa, fb;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, m;
    cin>>n>>m;
    int a[n];
    fa.resize(N, 0);
    fb.resize(N, 0);
    f(i, n) {
        cin>>a[i];
        fa[a[i]]++, fb[a[i]]++;
    }
    int ans = 0;
    vector<int> prod = multiply(fa, fb);
    for(int i = prod.size(); i >= 0; i--) {
        if(prod[i] >= m) {
            ans += i * m;
            m = 0;
            break;
        }
        else {
            ans += prod[i] * i;
            m -= prod[i];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 14920