#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());

    int ok = 0, ng = 200001;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;

        ll now = 0;
        for (int i = 0; i < n; i++)now += a.end() - lower_bound(a.begin(), a.end(), mid - a[i]);

        if (now >= m)ok = mid;
        else ng = mid;
    }

    vector<ll> c_sum(n + 1);
    for (int i = 0; i < n; i++)c_sum[i + 1] = c_sum[i] + a[i];

    ll ret = 0, count = 0;
    for (int i = 0; i < n; i++) {
        int x = a.end() - lower_bound(a.begin(), a.end(), ok - a[i]);
        ret += a[i] * x + c_sum[n] - c_sum[n - x];
        count += x;
    }

    cout << ret - ok * (count - m) << endl;
    return 0;
}