import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n;
  long m;
  readf (" %d %d", &n, &m);
  auto a = new int[n];
  foreach (t; 0 .. n) {
    readf (" %d", &a[t]);
  }
  auto e = sort (a);
  debug stderr.writeln (e);
  long c1, c2;
  bool check (const int x) {
    c1 = c2 = 0;
    foreach (y; a) {
      const int t = x - y;
      //c1 += e.upperBound (t).length;
      auto w = e.trisect (t);
      c1 += w[2].length;
      c2 += w[1].length;
    }
    return c1 + c2 >= m;
  }
  int l = 0, r = a.back + a.back + 1;
  while (r - l > 1) {
    int x = (l + r) >> 1;
    bool checkx = check (x);
    debug stderr.writefln ("check(%d) = %s", x, checkx);
    if (checkx) {
      l = x;
    } else {
      r = x; 
    }
  }
  check (l);
  debug stderr.writeln ("l = ", l);
  debug stderr.writeln ("c1 = ", c1);
  debug stderr.writeln ("c2 = ", c2);
  assert (c1 + c2 >= m);
  c2 = (m - c1);
  auto s = new long[n+1];
  foreach (i; 0 .. n) {
    s[i+1] = s[i] + a[i];
  }
  long res;
  foreach_reverse (y; a) {
    const int t = l - y;
    auto w = e.trisect (t);
    long l1 = w[2].length, l2 = w[1].length;
    c1 -= l1;
    assert (c1 >= 0);
    long u = l1;
    long q = min (c2, l2);
    c2 -= q;
    u += q;
    assert (c2 >= 0);
    res += u * y;
    assert (u <= n);
    res += s[n] - s[n-u];
  }
  assert (c1 == 0);
  assert (c2 == 0);
  writeln (res);
}

