#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}

#if 0
int main()
{
	ll n, m;
	cin >> n >> m;

	//vector<ll> v;

	ll a[n];
	priority_queue<int, std::vector<int>, std::greater<int> > q;

	
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		
		if (q.size() < m)
		{
			q.push(a[i]+a[i]);
			if (i > 0)
			{
				ll va = a[i] + a[i-1];
				if (q.size() < m)
				{
					q.push(va);
					if (q.size() < m)
					{
						q.push(va);
					}
					else
					{
						if (va > q.top())
						{
							q.pop();
							q.push(va);
						}
					}
					
				}
				else
				{
					int c = 0;
					while(c < 2)
					{
						if (q.top() > va)
						{
							break;
						}
						q.pop();
						q.push(va);
						c++;
					}
				}
				
			}
			
		}
		else
		{
			ll top = q.top();
			if (top < a[i] * 2)
			{
				q.pop();
				q.push(a[i] * 2);
			}
			if (i > 0)
			{
				ll va = a[i] + a[i-1];
				int c = 0;
				while(c < 2)
				{
					if (q.top() > va)
					{
						break;
					}
					q.pop();
					q.push(va);
					c++;
				}
			}

		}
		
	}
	
	

	return 0;
}
#endif

#define lli long long int

lli a[100010];
lli b[200020];
lli c[200020];
lli n, m;
lli fun1(lli x)
{
	lli res = 0ll;
	for (lli i = 1ll; i <= n; ++i)
		res += b[max(0ll, x - a[i])];
	return res;
}
lli fun2(lli x)
{
	lli res = 0ll;
	for (lli i = 1ll; i <= n; ++i)
		res += (c[max(0ll, x - a[i])] + a[i] * b[max(0ll, x - a[i])]);
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	for (lli i = 1ll; i <= n; ++i)
	{
		cin >> a[i];
		b[a[i]]++;
		c[a[i]] += a[i];
	}
	for (lli i = 100000ll; i >= 0ll; --i)
	{
		b[i] += b[i + 1];
		c[i] += c[i + 1];
	}
	lli l = 0ll, r = 200000ll, mid;
	while (l < r)
	{
		mid = (l + r + 1ll) / 2ll;
		if (fun1(mid) >= m)
			l = mid;
		else
			r = mid - 1ll;
	}
	cout << fun2(l + 1ll) + (m - fun1(l + 1ll))*l << endl;

	return 0;
}


Measured memory_bytes: 2560