#include<bits/stdc++.h>
using namespace std;
int main(){
int N;int64_t M;
  cin>>N>>M;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t left=0;int64_t right=2*A.at(N-1)+1;
  while(1<right-left){
  int64_t mid=left+(right-left)/2;
    int64_t sum=0;
    for(int i=0;i<N;i++){
    auto itr=lower_bound(A.begin(),A.end(),mid-A.at(i));
      int64_t k=distance(A.begin(),itr);
      sum+=N-k;
    }if(sum<M)
      right=mid;
    else
      left=mid;
  }vector<int64_t>B(N);
  B.at(N-1)=A.at(N-1);
  for(int i=N-2;0<=i;i--)
    B.at(i)=B.at(i+1)+A.at(i);
  int64_t ans=0; int64_t num=0;
  for(int i=0;i<N;i++){
  auto itr=lower_bound(A.begin(),A.end(),right-A.at(i));
    int k=distance(A.begin(),itr);
     if(k!=N){ans+=B.at(k)+A.at(i)*(N-k); num+=N-k;}
  }ans+=(M-num)*left;
  cout<<ans<<endl;
  
    return 0;
}