import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto A = aryread();
    auto s = new long[]((10 ^^ 5) + 1);
    foreach (a; A)
    {
        s[a]++;
    }
    foreach (i; 1 .. s.length)
    {
        s[i] = s[i] + s[i - 1];
    }
    long count(long x)
    {
        long ret;
        foreach (i; 0 .. N)
        {
            ret += N - s[max(0, x - A[i] - 1)];
        }
        return ret;
    }

    long ok = 0;
    long ng = 2 * 10 ^^ 5 + 1;
    while (1 < ng - ok)
    {
        long m = (ok + ng) / 2;
        if (count(m) < M)
        {
            ng = m;
        }
        else
        {
            ok = m;
        }
    }
    A.sort!"b<a"();
    long ans;
    long cnt;
    foreach (i; 0 .. N)
        foreach (j; 0 .. N)
            if (ok <= A[i] + A[j] && cnt < M)
            {
                cnt++;
                ans += A[i] + A[j];
            }
    writeln(ans);
}
