// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



using i64 = std::int_fast64_t;



#define REP(i, stop) FOR(i, 0, stop)

#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)

#define RREP(i, n) for (int i = n; i-- > 0;)

#define ALL(v) (v).begin(), (v).end()



template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }

template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }



struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;



signed main() {

  i64 N, M;

  cin >> N >> M;

  vector<i64> A(N);

  cin >> A;

  sort(ALL(A));

  vector<i64> S(N + 1);

  REP(i, N) S[i + 1] = S[i] + A[i];

  i64 h_ng = 0;

  i64 h_ok = A[N - 1] * 2 + 1;

  i64 h = h_ok;

  i64 ans = 0;

  while (h_ok > h_ng + 1) {

    h = (h_ok + h_ng) / 2;

    i64 s = 0;

    i64 q = 0;

    i64 r = 0;

    i64 ge = 0;

    i64 gt = 0;

    RREP(i, N) {

      while (ge < N && !(A[i] + A[ge] >= h)) ge++;

      while (gt < N && !(A[i] + A[gt] > h)) gt++;

      q += N - gt;

      r += gt - ge;

      s += S[N] - S[gt] + A[i] * (N - gt);

    }

    if (q <= M) {

      h_ok = h;

      if (M <= q + r) {

        cout << (s + (M - q) * h) << endl;

        exit(0);

      }

    } else {

      h_ng = h;

    }

  }

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

#include <vector>

using namespace std;



using i64 = long long;



#define REP(i, n) for (int i = 0, i##_len = n; i < i##_len; ++i)

#define RREP(i, n) for (int i = n; i-- > 0;)



const int is = 1 << 17;

char ib[is], *ip = ib + is, it;

inline char getc() {

	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }

	return *ip++;

}

inline i64 read() {

	i64 r = 0;

	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';

	else while ((it = *ip++) & 16) r = r * 10 + it - '0';

	return r;

}



const int os = 1 << 17;

char ob[os], *op = ob, ot;

inline void putc(const char c) {

	*op++ = c;

	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }

}

// x shoud be greater than or equal to zero

inline void write(i64 x) {

	char d[20];

	int i = 0;

	while (true) {

		d[i] = x % 10 + 48;

		x /= 10;

		++i;

		if (x <= 0) break;

	}

	while (i--) {

		putc(d[i]);

	}

}



signed main() {

  i64 N = read();

  i64 M = read();

  vector<i64> A(N);

  REP(i, N) A[i] = read();

  sort(A.begin(), A.end());

  vector<i64> S(N + 1);

  REP(i, N) S[i + 1] = S[i] + A[i];

  i64 h_ng = 0;

  i64 h_ok = A[N - 1] * 2 + 1;

  i64 h = h_ok;

  while (h_ok > h_ng + 1) {

    h = h_ng + h_ok >> 1;

    i64 q = 0;

    i64 gt = 0;

    RREP(i, N) {

      while (gt < N && !(A[i] + A[gt] > h)) gt++;

      q += N - gt;

    }

    if (q <= M) {

      h_ok = h;

    } else {

      h_ng = h;

    }

  }

  h = h_ok;

  i64 s = 0;

  i64 q = 0;

  i64 gt = 0;

  RREP(i, N) {

    while (gt < N && !(A[i] + A[gt] > h)) gt++;

    q += N - gt;

    s += S[N] - S[gt] + A[i] * (N - gt);

  }

  write(s + (M - q) * h);

  fwrite_unlocked(ob, 1, op - ob, stdout);

}


// Fastest known solution for this problem: