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

int main() {
    int64 N, M;
    cin >> N >> M;
    vector<int64> A(N), sum(N + 1);
    for(int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());
    for(int i = 0; i < N; ++i) sum[i + 1] = sum[i] + A[i];

    auto isOK = [&](int x) {
        int64 cnt = 0, total = 0;
        for(int i = 0; i < N; ++i) {
            int64 m = lower_bound(A.begin(), A.end(), x - A[i]) - A.begin();
            cnt += N - m;
            total += sum[N] - sum[m];
            total += A[i] * (int64)(N - m);
        }
        return make_pair(cnt, total);
    };
    int l = 0, r = 200005;
    while(r - l > 1) {
        int mid = (l + r) / 2;
        if(isOK(mid).first >= M) l = mid;
        else r = mid;
    }
    auto ans = isOK(l);
    cout << ans.second - l * (int64)(ans.first - M) << '\n';
    return 0;
}
