#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int A[100010];
ll ruis[100010];

int main() {
	ll N, M;
	cin >> N >> M;
	for(int i=0; i<N; ++i) cin >> A[i];
	sort(A, A+N);
	A[N]=200010;
	int ok=0, ng=200010;
	while(ok+1<ng){
		int mid=(ok+ng)/2, now=N;
		ll sum=0;
		for(int i=0; i<N; ++i){
			while(now>0){
				if(A[i]+A[now-1]>=mid) --now;
				else break;
			}
			sum += N-now;
		}
		if(M<=sum) ok=mid;
		else ng=mid;
	}
	for(int i=0; i<N; ++i) ruis[i+1]=ruis[i]+A[i];
	int nn=N;
	ll cnt=0, ans=0;
	for(int i=0; i<N; ++i){
		while(nn>0){
			if(A[i]+A[nn-1]>=ok) --nn;
			else break;
		}
		ans += ruis[N]-ruis[nn]+A[i]*(N-nn);
		cnt += N-nn;
	}
	ans -= (cnt-M)*ok;
	cout << ans << endl;
	return 0;
}