#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
ll n,m;
ll a[100009],sum[100009];
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
    ll l=0,r=2e5+1,ans,cnt,res;
    while(l<=r){
        ll mid=(l+r)>>1;
        res=cnt=0;
        for(ll i=1;i<=n;i++){
            ll pos=lower_bound(a+1,a+n+1,mid-a[i])-a;
            cnt+=n-pos+1;
            res+=sum[n]-sum[pos-1]+a[i]*(n-pos+1);
        }
        if(cnt>=m){
            ans=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    printf("%lld\n",res-(cnt-m)*ans);
    return 0;
}
