#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int n;
ll k;
int a[maxn]; 
ll sum[maxn];
ll calc(int x)
{
	ll ret = 0;
	for(int i = 1; i <= n; ++i)
		ret += upper_bound(a + 1, a + n + 1, x - a[i], greater<int>()) - 1 - a;
	return ret;
}
void solve(int x)
{
	ll ans = 0;
	for(int i = 1; i <= n; ++i)
	{
		int r = lower_bound(a + 1, a + n + 1, x - a[i], greater<int>()) - 1 - a;
		ans += sum[r] + 1ll * a[i] * r;
		k -= r;
	}
	ans += k * x;
	printf("%lld\n", ans);
}
int main()
{
	scanf("%d%lld", &n, &k);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1, greater<int>());
	for(int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i];
	int l = 2, r = 2e5;
	while(l <= r)
	{
		int mid = l + r >> 1;
		if(calc(mid) >= k)
			l = mid + 1;
		else
			r = mid - 1;
	}
	solve(r);
	return 0;
}
		