#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

int main() {
    int n;
    long long m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    int lb = -1, ub = 2e5+1;
    while (ub - lb > 1) {
        int t = (lb + ub) / 2;
        long long count = 0;
        for (int i = 0; i < n; i++)
            count += a.rend() - lower_bound(a.rbegin(), a.rend(), t-a[i]);
        if (count < m) ub = t;
        else lb = t;
    }
    vector<long long> s(n+1, 0);
    for (int i = 0; i < n; i++) s[i+1] = s[i] + a[i];
    long long count = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        int j = a.rend() - lower_bound(a.rbegin(), a.rend(), ub-a[i]);
        ans += (long long)a[i] * j + s[j];
        count += j;
    }
    ans += lb * (m - count);
    cout << ans << endl;
}
