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

long long n, m;
int a[100000];

int get_lower_limit() {
  int l = 0, r = 2 * 1e5 + 1;
  while (l < r - 1) {
    long long cnt = 0;
    int mid = (l + r) / 2;
    for (int i=0; i<n; i++) {
      auto it = lower_bound(a, a + n, mid - a[i]);
      cnt += (a + n - it);
    }
    if (cnt >= m) {
      l = mid;
    } else {
      r = mid;
    }
  }
  return l;
}
int main() {
  cin>>n>>m;
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a, a + n);
  int lower_limit = get_lower_limit();
  long long acc[n+1];
  acc[0] = 0;
  for (int i=1; i<n+1; i++) {
    acc[i] = acc[i-1] + a[i-1];
  }
  long long ans = 0;
  long long cnt = 0;
  for (int i=0; i<n; i++) {
    auto it = upper_bound(a, a + n, lower_limit - a[i]);
    cnt += (a + n - it);
    int idx = it - a;
    ans += acc[n] - acc[idx] + 1LL * (a + n - it) * a[i];
  }
  ans += 1LL * (m - cnt) * lower_limit;
  cout<<ans<<endl;
}