#include <bits/stdc++.h>
using namespace std; 
int main(){
	int N; cin >> N; 
	long long M; cin >> M; 
	long long A[100010]; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	sort(A, A+N); 
	int ok = 0; int ng = 200001; long long cnt = 0; 
	while(ng - ok > 1){
		int mid = (ok + ng) / 2;  
		cnt = 0;  
		for(int i = 0; i < N; i++){
			int a = lower_bound(A, A+N, mid - A[i]) - A;
			cnt += (long long) N - a; 
		}
		if(cnt >= M) ok = mid; 
		else ng = mid; 
	}
	long long S[100010] = {}; 
	S[0] = A[0]; long long cnt2 = 0; 
	for(int i = 1; i < N; i++) S[i] = S[i-1] + A[i]; 
	long long ans = 0; 
	for(int i = 0; i < N; i++){
		int a = lower_bound(A, A+N, ok - A[i]) - A; cnt2 += (long long) N - a; 
		if(a == 0) ans += N * A[i] + S[N-1]; 
		else ans += ((long long) N - a) * A[i] + S[N-1] - S[a-1]; 
	}
	cout << ans - (cnt2 - M) * ok << endl; 
}