#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll N,M;
  cin >> N >> M;
  vector<ll> A(N);
  for(ll i=0;i<N;i++) cin >> A[i];

  sort(A.begin(),A.end(),greater<ll>());

  ll l=0,r=200010;
  ll m=0,n=0;
  ll v;
  ll tot=0;

  while(l+1<r){
    tot=0;
    n=N-1;
    v=(l+r)/2;
    for(ll i=0;i<N;i++){
      while(A[n]+A[i]<v && 0<=n) n--;
      tot+=n+1;
    }
    if(tot<M) r=v; else l=v;
  }
  
  vector<ll> s(N,0);
  tot=0;
  for(ll i=0;i<N;i++){
    tot+=A[i]; s[i]=tot;
  }

  tot=0;
  ll ans=0;
  n=N-1;
  for(ll i=0;i<N;i++){
    while(A[n]+A[i]<r && 0<=n) n--;
    if(n>=0) ans+=s[n]+A[i]*(n+1);
    tot+=n+1;
  }
  ans+=l*(M-tot);

  cout << ans << endl;
  
  return 0;
}
