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

typedef long long ll;

const ll INF = LLONG_MAX;
const int mxn= 1e5 + 5;
int a[mxn];
ll dp[mxn];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
	ll n , m; 
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort (a, a + n);

	int le = 0, ri = 2e5 + 1;
	ll cnt, happiness = 0LL;
  while (le <= ri) {
    int mid = (le + ri)/2;
    cnt = 0;
    for (int i = 0; i < n; i++) {
      ll ptr = lower_bound(a, a + n, mid - a[i]) - a;
      cnt += n - ptr;
    }
    if (cnt > m) {
      le = mid + 1;
    } else {
      ri = mid - 1;
    }
  }

	le--;
	cnt = 0LL;

  // compute suffix sums
	for (int i = n - 1; i >= 0; i--) {
		dp[i] = dp[i + 1] + (ll) a[i];
	}

	for (int i = 0; i < n; i++) {
		int left = a[i];
		ll ptr = lower_bound(a, a + n, le - left) - a;
		cnt += n - ptr;
		happiness += dp[ptr] + (n - ptr) * left;
	}

	cnt = cnt - m;
	happiness -= cnt * le;
	cout << happiness << endl;
}
