#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000000
#define MOD 1000000007
using Graph=vector<vector<int>>;

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  vector<ll> B=A;
  reverse(A.begin(),A.end());

  vector<ll> sum(N+1,0);
  for(int i=0;i<N;i++){
    sum.at(i+1)=sum.at(i)+A.at(i);
  }

  //A降順
  //B昇順

  ll left=0;
  ll right=10000000000;
  while(left+1<right){
    ll x=(left+right)/2;
    ll count=0;
    for(int i=0;i<N;i++){
      int k=lower_bound(B.begin(),B.end(),x-A.at(i))-B.begin();
      count+=N-k;
    }
    if(count>=M){
      left=x;
    }else{
      right=x;
    }
  }

  ll count=0;
  ll ans=0;
  for(int i=0;i<N;i++){
    int k=lower_bound(B.begin(),B.end(),left-A.at(i))-B.begin();
    ans+=sum.at(N-k)+A.at(i)*((ll)N-(ll)k);
    count+=N-k;
  }
  ans-=left*(count-M);
  cout<<ans<<endl;
}
