#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

ll N;
ll A[100000];
ll M, res, S[100001];

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	int L, R;
	L = 0, R = 222222;
	ll t;
	while (L + 1 != R) {
		int m = (L + R) / 2;
		t = 0;
		for (int i = 0; i < N; i++) {
			t += A + N - lower_bound(A, A + N, m - A[i]);
		}
		if (t >= M) {
			L = m;
		}
		else {
			R = m;
		}
	}
	t = 0;
	for (int i = 0; i < N; i++) {
		t += A + N - lower_bound(A, A + N, L - A[i]);
	}
	for (int i = N - 1; i >= 0; i--) {
		S[i] = S[i + 1] + A[i];
	}
	for (int i = 0; i < N; i++) {
		res += (N-(lower_bound(A, A + N, L - A[i]) - A))*A[i];
	}
	cout << res*2- (t - M)*L << endl;
}