#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, M, L = 0, R = 1000000000000;
	vector<long long> A;
	map<long long, long long> mp;
	cin >> N >> M;
	A.resize(N);
	for (int i = 0; i < N; i++) cin >> A[i], mp[A[i]]++;
	sort(A.begin(), A.end());
	while (R - L > 1) {
		long long MID = (L + R) / 2;
		long long COUNT = 0;
		for (int i = 0; i < N; i++) {
			COUNT += A.end() - lower_bound(A.begin(), A.end(), MID - A[i]);
		}
		if (COUNT >= M) L = MID;
		else R = MID;
	}
	long long MORE = 0, ANS = 0;
	vector<long long> SUM(N + 1);
	SUM[0] = 0;
	for (int i = 0; i < N; i++) SUM[i + 1] = SUM[i] + A[i];
	for (int i = 0; i < N; i++) {
		long long X = upper_bound(A.begin(), A.end(), L - A[i]) - A.begin();
		ANS += SUM[N] - SUM[X];
		ANS += A[i] * (N - X);
		MORE += N - X;
	}
	ANS += L * (M - MORE);
	cout << ANS << endl;
}