#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll N,M;
vector<ll> A;
vector<ll> idx;
ll sum;
bool f(ll mid){
    sum=0;
    rep(0,i,N){
        idx[i]=lower_bound(A.begin(),A.end(),mid-A[i])-A.begin();//左手をiとしてmid1より少ない握手した時の組み合わせの数。
        sum+=N-idx[i];//sum=(すべての組み合わせの数)
    }
    return sum>=M;
}
int main(void){
    // Your code here!
    cin>>N>>M;
    A.resize(N);
    idx.resize(N);
    rep(0,i,N)cin>>A[i];
    sort(A.begin(),A.end());
    ll left=-1,right=1e6;
    while(left+1<right){
        ll mid=(left+right)/2;
        if(f(mid))left=mid;
        else right=mid;
    }
    f(left);
    ll ans=0;
    rep(0,i,N)ans+=(N-idx[i])*A[i]*2;
    ans-=(sum-M)*left;
    cout<<ans<<endl;
}
