#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
long long M;
int A[100000];
long long sm[100000+1];
int main(){
  wmem = memarr;
  int i;
  int j;
  int x;
  long long ok;
  long long res = 0;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  sortA_L(N,A);
  for(i=(0);i<(N);i++){
    sm[i+1] = sm[i] + A[i];
  }
  int RZTsC2BF;
  int FmcKpFmN;
  int xr20shxY;
  RZTsC2BF = 0;
  FmcKpFmN = 200000;
  while(RZTsC2BF < FmcKpFmN){
    if((RZTsC2BF + FmcKpFmN)%2==0){
      xr20shxY = (RZTsC2BF + FmcKpFmN) / 2;
    }
    else{
      xr20shxY = (RZTsC2BF + FmcKpFmN + 1) / 2;
    }
    ok = 0;
    j = 0;
    for(i=(N)-1;i>=(0);i--){
      while(j < N && A[i] + A[j] < xr20shxY){
        j++;
      }
      if(j==N){
        break;
      }
      ok += N - j;
    }
    if(ok >= M){
      RZTsC2BF = xr20shxY;
    }
    else{
      FmcKpFmN = xr20shxY - 1;
    }
  }
  x =FmcKpFmN;
  ok = 0;
  j = 0;
  for(i=(N)-1;i>=(0);i--){
    while(j < N && A[i] + A[j] < x){
      j++;
    }
    if(j==N){
      break;
    }
    ok += N - j;
    res += (long long) A[i] * (N-j);
    res += sm[N] - sm[j];
  }
  res -= (ok - M) * x;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191229-1 [beta]

// --- original code ---
// int N; ll M;
// int A[1d5];
// ll sm[1d5+1];
// {
//   int i, j, x;
//   ll ok, res = 0;
//   rd(N,M,A(N));
//   sortA(N,A);
// 
//   rep(i,N) sm[i+1] = sm[i] + A[i];
// 
//   x = bsearch_max[int,x,0,2d5][
//     ok = 0;
//     j = 0;
//     rrep(i,N){
//       while(j < N && A[i] + A[j] < x) j++;
//       if(j==N) break;
//       ok += N - j;
//     }
//   ](ok >= M);
// 
//   ok = 0;
//   j = 0;
//   rrep(i,N){
//     while(j < N && A[i] + A[j] < x) j++;
//     if(j==N) break;
//     ok += N - j;
//     res += (ll) A[i] * (N-j);
//     res += sm[N] - sm[j];
//   }
//   res -= (ok - M) * x;
//   wt(res);
// }


Measured memory_bytes: 1408