#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);


    ll n,m;
    cin>>n>>m;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll low = -1, up = 1e15;
    while(up-low>1){
        ll mid = (up+low)/2;
        ll cnt = 0;
        for(int i=0;i<n;i++){
            cnt += a+n - lower_bound(a,a+n,mid-a[i]);
            //cerr << mid << " " << i << " " << cnt << endl;
        }
        if(cnt >= m) low = mid;
        else up = mid;
    }
    cerr << low << endl;
    ll ans = 0;
    ll cnt = 0;
    for(int i=0;i<n;i++){
        ll ret = (a+n - upper_bound(a,a+n,low-a[i]));
        ans += a[i] * ret *2;
        cnt += ret;
    }
    cerr << cnt << endl;
    ans += low * (m-cnt);
    cout << ans << endl;
    
}