#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 100100
using namespace std;

long long A[MAX];
int main()
{
	long long N, M; scanf("%lld%lld", &N, &M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	std::sort(A, A + N);

	long long st, mid, ed, res, ss;
	st = 0; ed = 200005;
	while (st<=ed) {
		mid = (st + ed) / 2;
		long long sum = 0, t = N;
		for (int i = 0; i < N; i++) {
			while (true) {
				if (t == 0 || A[t - 1] + A[i] < mid) break;
				t--;
			}
			sum += N - t;
		}
		if (sum <= M) {
			res = mid;
			ed = mid - 1;
			ss = sum;
		}
		else st = mid + 1;
	}

	long long t = N;
	long long ans = (long long)(M - ss) * (res - 1), sum = 0;
	for (int i = 0; i < N; i++) {
		while (true) {
			if (t == 0 || A[t - 1] + A[i] < res) break;
			t--;
			sum += A[t];
		}
		ans += (long long)(A[i])*(N - t) + sum;
	}
	printf("%lld", ans);
	return 0;
}