//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

class FFTconvolution
{
public:
    //遅かったら自作クラスで代替
    using kotonoha = complex<double>;

    //N : convoluted sequence legnth
    //M : power of 2
    int N, M, logM;
    const double PI = acos(-1.0);
    vector<kotonoha> a, b;

    FFTconvolution(const vector<double> &a_, const vector<double> &b_)
    {
        int na_ = a_.size(), nb_ = b_.size();
        N = na_ + nb_ - 1;
        M = 1;
        logM = 0;
        while (M < N)
        {
            M <<= 1;
            ++logM;
        }
        a.resize(M);
        b.resize(M);
        for (int i = 0; i < na_; i++)
        {
            a[i] = kotonoha(a_[i], 0);
        }
        for (int i = 0; i < nb_; i++)
        {
            b[i] = kotonoha(b_[i], 0);
        }
    }

    vector<kotonoha> convolve()
    {
        vector<kotonoha> A = fft(a), B = fft(b), C(M);
        for (int i = 0; i < M; i++)
        {
            C[i] = A[i] * B[i];
        }
        vector<kotonoha> c = fft(C, true);
        c.resize(N);
        return c;
    }

    //vector size must be power of 2
    vector<kotonoha> fft(const vector<kotonoha> &a, bool inverse = false)
    {
        //入れ替え
        vector<kotonoha> na(M);
        for (int i = 0; i < M; i++)
        {
            int ni = 0;
            for (int j = 0; j < logM; j++)
            {
                if (i >> (logM - j - 1) & 1)
                {
                    ni |= 1 << j;
                }
            }
            na[i] = a[ni];
        }
        for (int b = 1; b < M; b <<= 1)
        {
            vector<kotonoha> nna(M);
            for (int j = 0; j < b; j++)
            {
                kotonoha w = polar(1.0, PI / b * j * (inverse ? 1 : -1));
                for (int k = 0; k < M; k += b * 2)
                {
                    nna[j + k] = na[j + k] + na[j + k + b] * w;
                    nna[j + k + b] = na[j + k] - na[j + k + b] * w;
                }
            }
            swap(na, nna);
        }
        if (inverse)
        {
            for (int i = 0; i < M; i++)
            {
                na[i] /= M;
            }
        }
        return na;
    }

    // vector<complex<double>> fft(const vector<double> &a)
    // {
    // }
};

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 n, m;
    cin >> n >> m;
    akari<double> as(100010);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        as[a]++;
    }
    auto bs = as;
    FFTconvolution fft(as, bs);
    auto cs = fft.convolve();
    int sz = cs.size();
    i64 ans = 0;
    for (int i = sz - 1; i >= 0 && m; i--)
    {
        i64 use = min((i64)round(cs[i].real()), m);
        m -= use;
        ans += i * use;
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 30712