#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int n;
ll m;
l_l calc(int mid,vector<int> a,vector<ll> sum){
    ll total=0,num=0;
    for(int i=0; i<n; i++){
        int j=lower_bound(a.begin(),a.end(),mid-a[i])-a.begin();
        num+=n-j;
        total+=sum[n]-sum[j];
        total+=a[i]*ll(n-j);
    }
    return l_l(total,num);
}
int main(){
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    vector<ll> sum(n+1);
    sort(a.begin(),a.end());
    for(int i=0; i<n; i++) sum[i+1]=sum[i]+a[i];
    int l=0,r=200005;
    while(r-l>1){
        int mid=(r+l)/2;
        if(calc(mid,a,sum).second>=m) l=mid;
        else r=mid;
    }
    auto p=calc(l,a,sum);
    ll ans=p.first;
    ans-=(p.second-m)*l;
    cout << ans << endl;
    return 0;
}