#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), S(N + 1, 0);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    rep(i, N) S[i + 1] = S[i] + A[i];
    ll l = 0, h = 1e18;
    while (l + 1 < h) {
        ll m = (l + h) / 2, c = 0;
        rep(i, N) {
            c += A.end() - lower_bound(A.begin(), A.end(), m - A[i]);
            //cout << "m=" << m << " i=" << i << " c=" << c << "\n";
        }
        if (c >= M) l = m;
        else h = m;
    }
    //cout << "l=" << l << "\n";
    ll ans = 0, c = 0;
    rep(i, N) {
        int j = lower_bound(A.begin(), A.end(), l - A[i]) - A.begin();
        c += N - j;
        ans += S[N] - S[j] + A[i] * (N - j);
    }
    if (c > M) ans -= (c - M) * l;
    cout << ans << "\n";
    //rep(i, N + 1) cout << S[i] << "\n";
}