#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 1e5+7 ;
const int INF = 1e9 ;
const int MOD = INF + 7 ;
struct fft{
	struct compleX{
		double real,imag;
		compleX(){
		    real = imag = 0;
		}
		compleX(double a,double b){
		    real = a; imag = b;
		}
		inline compleX operator +(const compleX &x) const { return {real+x.real, imag+x.imag}; }
		inline compleX operator -(const compleX &x) const { return {real-x.real, imag-x.imag}; }
		inline compleX operator *(const compleX &x) const { return {real*x.real-imag*x.imag, real*x.imag+imag*x.real}; }
		inline compleX operator *(const double  &y) const { return {real*y, imag*y}; }
	};
	inline compleX conj(compleX x) const { return {x.real,-x.imag}; }

	const int MOD = 998244353;
	const double PI = acos(-1);
	typedef compleX Complex;

	//Nは畳み込んだ後のサイズ以上
	//複数回使う場合、Nは最大サイズにしておけばInitを1回呼ぶだけでよい
	const int N = (1<<18), L = 15, MASK = (1 << L) - 1;
	vector<Complex>w[21];
	fft(){
		int up =  log2(N);
		w[up].resize(N);
		for (int i = 0; i < N; ++i) {
			w[up][i] = Complex(cos(2 * i * PI / N), sin(2 * i * PI / N));
		}
		for(int i=up-1;i>=0;i--){
		    w[i].resize((1<<i));
		    for(int j=0;j<(1<<i);j++){
		        w[i][j] = w[i+1][j<<1];
		    }
		}
	}
	void FFT(vector<Complex>&p, int n) {
		for (int i = 1, j = 0; i < n - 1; ++i) {
			for (int s = n; j ^= s >>= 1, ~j & s;);
			if (i < j) {
				swap(p[i], p[j]);
			}
		}
		for (int d = 0; (1 << d) < n; ++d) {
			int m = 1 << d, m2 = m * 2, rm = n >> (d + 1);
			for (int i = 0; i < n; i += m2) {
				for (int j = 0; j < m; ++j) {
					Complex &p1 = p[i + j + m], &p2 = p[i + j];
					Complex t = w[d+1][j] * p1;
					p1 = p2 - t;
					p2 = p2 + t;
				}
			}
		}
	}
	void IFFT(vector<Complex>&p, int n){
		FFT(p,n);
		reverse(p.begin()+1, p.end());
		double in = 1.0 / (double)(n);
		for(int i=0;i<n;i++) p[i] = p[i] * in;
	}
	vector<int> mul(vector<int>a,vector<int>b){
		int NN = 1;
        while(NN < a.size()+b.size()) NN <<= 1;
	    vector<Complex>A(NN), B(NN), C(NN);
	    a.resize(NN,0); b.resize(NN,0);
		for (int i = 0; i < NN; ++i) {
			A[i] = Complex(a[i], 0.0);
			B[i] = Complex(b[i], 0.0);
		}
		FFT(A, NN), FFT(B, NN);
		for (int i = 0; i < NN; ++i) {
			C[i] = A[i] * B[i];
		}
		IFFT(C, NN);
		vector<int>ret(NN);
		for (int i = 0; i < NN; ++i) {
			int da = (int)(C[i].real + 0.5);
			ret[i] = da;
		}
		return ret;
	}
	vector<int> mod_mul(vector<int>a,vector<int>b){
        int NN = 1;
        while(NN < a.size()+b.size()) NN <<= 1;
        vector<Complex>A(NN), B(NN), C(NN), D(NN);
        a.resize(NN,0); b.resize(NN,0);
        for (int i = 0; i < NN; ++i) {
            A[i] = Complex(a[i] >> L, a[i] & MASK);
            B[i] = Complex(b[i] >> L, b[i] & MASK);
        }
		FFT(A, NN); FFT(B, NN);
		for (int i = 0; i < NN; ++i) {
			int j = (NN - i) % NN;
			Complex da = (A[i] - conj(A[j])) * Complex(0, -0.5),
					db = (A[i] + conj(A[j])) * Complex(0.5, 0),
					dc = (B[i] - conj(B[j])) * Complex(0, -0.5),
					dd = (B[i] + conj(B[j])) * Complex(0.5, 0);
			C[j] = da * dd + da * dc * Complex(0, 1);
			D[j] = db * dd + db * dc * Complex(0, 1);
		}
		FFT(C, NN); FFT(D, NN);
		vector<int>ret(NN);
		for (int i = 0; i < NN; ++i) {
			long long da = (long long)(C[i].imag / NN + 0.5) % MOD,
					  db = (long long)(C[i].real / NN + 0.5) % MOD,
					  dc = (long long)(D[i].imag / NN + 0.5) % MOD,
					  dd = (long long)(D[i].real / NN + 0.5) % MOD;
			ret[i] = ((dd << (L * 2)) + ((db + dc) << L) + da) % MOD;
		}
		return ret;
	}
} ;

int32_t main(){
	int n , k ;
	cin >> n >> k ;
	vector<int> a(n) ;
	vector<int> cnt(N) ;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i] ;
		cnt[a[i]]++ ;
	}
	fft F ;
	int ans = 0 ;
	vector<int> b = F.mul(cnt,cnt) ;
	for(int i = b.size()-1 ; i >= 0 ; i--){
		long long x = min(k,b[i]) ;
		k -= x ;
		ans += (x*i) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 28512