using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// using System.Numerics;
using System.Runtime.CompilerServices;
using ll=System.Int64;
using static MyIO;

public class Contest
{
	static void Swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
	static void Swap2<T>(ref T a, ref T b) where T : IComparable { if (a.CompareTo(b)==1) Swap1(ref a, ref b); }  // b の方が小さければ交換
	static bool Chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; }  // b の方が小さければ a を更新
	static bool Chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; }  // b の方が大きければ a を更新
	static T[][] InitMat<T>(long len1, long len2, T val) where T : struct { T[][] m = new T[len1][]; for (int i = 0; i < m.Length; i++) m[i] = Enumerable.Repeat(val, (int)len2).ToArray(); return m; }
	static T[][][] InitMat<T>(long len1, long len2, long len3, T val) where T : struct { T[][][] m = new T[len1][][]; for (int i = 0; i < m.Length; i++) m[i] = InitMat(len2,len3,val); return m; }
	public const long MOD1 = 1000000007; // 10^9+7
	public const double EPS1 = 1e-8;
	public const long INF1 = 1000000000000000;  // 10^15

	public static void Main() {
		Solve_E();
 	}

	public static void Solve_A() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);



		long ans = 0;


		MyIO.WriteMulti(ans);
	}
	public static void Solve_B() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);



		long ans = 0;


		MyIO.WriteMulti(ans);
	}
	public static void Solve_C() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);



		long ans = 0;


		MyIO.WriteMulti(ans);
	}
	public static void Solve_D() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);



		long ans = 0;


		MyIO.WriteMulti(ans);
	}
	public static void Solve_E() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);
		ll[] a;
		ReadArray(out a);
 
		ll[] p = new ll[100001];
		foreach (var e in a)
		{
			p[e]++;
		}
  
		NTTWrapper ntt = new NTTWrapper(1000000000000000);
		ll[] b = ntt.Multiply(p,p);
		ll ans = 0;
		for (ll i = b.Length-1; 0<=i; i--)
		{
			if(b[i]<m){
				ans += i*b[i];
				m -= b[i];
			}else{
				ans += i*m;
				m = 0;
				break;
			}
		}
 		MyIO.WriteMulti(ans);
  

	}
	public static void Solve_F() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);



		long ans = 0;


		MyIO.WriteMulti(ans);
	}


public class NTTWrapper {
	private long[] _nttmods;
	private NumberTheoreticTransform[] _nttcalc;
	private long _mod;
	public NTTWrapper(long mod){
		_nttmods = new long[] {
			2025848833,	// n=22 k=483 b=31 o=5
			2088763393,	// n=23 k=249 b=31 o=5
			2013265921,	// n=27 k=15 b=31 o=11
			1811939329,	// n=26 k=27 b=31 o=11
			2113929217,	// n=25 k=63 b=31 o=5
			2130706433,	// n=24 k=127 b=31 o=3
		};

		_nttcalc = new NumberTheoreticTransform[_nttmods.Length];
		for (int i = 0; i < _nttcalc.Length; i++) _nttcalc[i] = new NumberTheoreticTransform(_nttmods[i]);

		_mod = mod;
	}

	public long[] Multiply(long[] A, long[] B) {
		long maxa = 0;
		long maxb = 0;
		for (int i = 0; i < A.Length; i++) if(maxa<A[i]) maxa = A[i];
		for (int i = 0; i < B.Length; i++) if(maxb<B[i]) maxb = B[i];
		long maxv = maxa*maxb*Math.Min(A.Length,B.Length);
		int mlen = 0;
		long mprod = 1;
		for (int i = 0; i < _nttmods.Length; i++) {
			mprod *= _nttmods[i];
			mlen++;
			if(maxv<mprod) break;
		}

		long[][] CC = new long[mlen][]; 
		for (int i = 0; i < mlen; i++) CC[i] = _nttcalc[i].Multiply(A, B);
		long[] ret = new long[CC[0].Length];
		long[] vals = new long[mlen];
		long[] mods = new long[mlen];
		Array.Copy(_nttmods, mods, mlen); 
		for (int j = 0; j < CC[0].Length; j++) {
			for (int i = 0; i < mlen; i++) vals[i] = CC[i][j];
			ret[j] = Garner(vals, mods, _mod);
		}
		return ret;
	}

}

public class NumberTheoreticTransform {
	private long[] _rts = {0, 1};
	private int[] _rev = {0, 1};
	private int _bas = 1;
	private readonly int _maxbas;
	private readonly long _mod, _root;

	public NumberTheoreticTransform() : this(1012924417) {}
	public NumberTheoreticTransform(long modulo) {
		if (modulo < 3 || modulo % 2 == 0) throw new ArgumentException("Invalid modulo", "modulo");
		_mod = modulo;
		long tmp = _mod - 1;
		_maxbas = 0;
		while(tmp % 2 == 0) {
			tmp >>= 1;
			_maxbas++;
		}
		long prim_root = 2;
		while(mod_pow(prim_root, (_mod - 1) >> 1) == 1) ++prim_root;
		if (mod_pow(prim_root, _mod - 1) != 1) throw new ArgumentException("Invalid prim_root", "prim_root");
		_root = mod_pow(prim_root, (_mod - 1) >> _maxbas);
	}

	private void ensure_base(int N) {
		if(N<=_bas) return;
		Array.Resize(ref _rts, 1<<N);
		Array.Resize(ref _rev, 1<<N);
		for(int i = 0; i < (1 << N); i++) _rev[i] = (_rev[i >> 1] >> 1) + ((i & 1) << (N - 1)); 
		if (_maxbas < N) throw new ArgumentException("Invalid nbase", "N");
		while(_bas < N) {
			long z = mod_pow(_root, 1L << (_maxbas - 1 - _bas));
			for(int i = 1 << (_bas - 1); i < (1 << _bas); i++) {
				_rts[i << 1] = _rts[i];
				_rts[(i << 1) + 1] = mul(_rts[i], z);
			}
			++_bas;
		}
	}

	[MethodImpl(256)] private long mod_pow(long x, long n) {
		long ret = 1;
		while(n > 0) {
			if(0<(n & 1)) ret = mul(ret, x);
			x = mul(x, x);
			n >>= 1;
		}
		return ret;
	}
//	[MethodImpl(256)] private long mod_pow(System.Numerics.BigInteger x, System.Numerics.BigInteger n) => (long)System.Numerics.BigInteger.ModPow(x, n, _mod);

	[MethodImpl(256)] private long inverse(long x) => mod_pow(x, _mod - 2);
	[MethodImpl(256)] private long add(long x, long y) {
		x += y;
		if(x >= _mod) x -= _mod;
		return x;
	}

	[MethodImpl(256)] private long mul(long a, long b) => checked(a * b) % _mod;
//	[MethodImpl(256)] private long mul(System.Numerics.BigInteger a, System.Numerics.BigInteger b) => (long)(a * b % _mod);
//	[MethodImpl(256)] private long mul(long a, long b) {	// BigInteger より遅い (long:1 BinInt:3 decimal:5  FFT(double):0.6 )
//		long c = (a * b - (long)((decimal) a * b / _mod) * _mod) % _mod;
//		return c < 0 ? c + _mod : c;
//	}

	public void NTT(long[] F) {
		int n = F.Length;
		if ((n & (n - 1)) != 0) throw new ArgumentException("Invalid size", "n");
		int zeros = 0;
		if(0<n){
			int nn = n;
			while((nn&1)==0){
				zeros++;
				nn>>=1;
			}
		}
		ensure_base(zeros);
		int shift = _bas - zeros;
		for(int i = 0; i < n; i++) {
			int j = (_rev[i] >> shift);
			if(i < j) { var t = F[j]; F[j] = F[i]; F[i] = t; }
		}
		for(int k = 1; k < n; k <<= 1) {
			for(int i = 0; i < n; i += 2 * k) {
				for(int j = 0; j < k; j++) {
					var z = mul(F[i + j + k], _rts[j + k]);
					F[i + j + k] = add(F[i + j], _mod - z);
					F[i + j] = add(F[i + j], z);
				}
			}
		}
	}

	public long[] Multiply(long[] A, long[] B) {
		int need = A.Length + B.Length - 1;
		int nbase = 1;
		while((1 << nbase) < need) nbase++;
		ensure_base(nbase);
		int sz = 1 << nbase;
		var da = new long[sz];
		var db = new long[sz];
		for (int i = 0; i < A.Length; i++) da[i] = A[i];
		for (int i = 0; i < B.Length; i++) db[i] = B[i];
		NTT(da);
		NTT(db);
		var inv_sz = inverse(sz);
		var dc = new long[sz];
		dc[0] = mul(da[0], mul(db[0], inv_sz));
		for(int i = 1; i < sz; i++) dc[sz-i] = mul(da[i], mul(db[i], inv_sz));
		NTT(dc);
		Array.Resize(ref dc, need);
		return dc;
	}

}

	public static long Garner(long[] b, long[] m, long MOD=9223372036854775783L) {
		long lcm;
		if((lcm = PreGarner(ref b, ref m, MOD))==-1) return -1;	// 前処理不要ならコメントアウト
		var q = new long[m.Length+1];
		Array.Copy(m,q,m.Length);
		q[q.Length-1] = MOD; // 番兵
		long[] coeffs = Enumerable.Repeat(1L,q.Length).ToArray();
		long[] constants = Enumerable.Repeat(0L,q.Length).ToArray();
		for (int k = 0; k < b.Length; ++k) {
			long t = (b[k] - constants[k]) * ModInv(coeffs[k], q[k]) % q[k];
			t += (t<0)?q[k]:0;
			for (int i = k+1; i < q.Length; ++i) {
				constants[i] = (constants[i] + t * coeffs[i]) % q[i];
				coeffs[i] = (coeffs[i] * q[k]) % q[i];
			}
		}
		return constants[constants.Length-1];
	}
	// Garner のアルゴリズムの前処理 mが互いに素ではない場合
	public static long PreGarner(ref long[] b, ref long[] m, long MOD=9223372036854775783L) {
		for (int i = 0; i < b.Length; ++i) {
			for (int j = 0; j < i; ++j) {
				long g = GCD(m[i], m[j]);
				// これを満たさなければ解はない
				if ((b[i] - b[j]) % g != 0) return -1;
				// s = m[i], t = m[j] を仮想的に素因数分解して s = p^k ... q^l ..., t = q^m ... r^n ... となったときに
				m[i] /= g; // p については i の方が大きかったものについての j との差分、と q
				m[j] /= g; // p については j の方が大きかったものについての i との差分、と r
				// 残る g を i と j に振り分ける (i の方が指数大きかった素因子 p の分は最終的に gi に、j の方が指数大きかった素因子 p の分は最終的に gj に)
				// ひとまず j 側にある p については gj のみに行くようにする
				long gi = GCD(m[i], g), gj = g/gi;
				// 本来 i 側に行くべき p で gj 側にあるものを gi 側に寄せていく
				do {
					g = GCD(gi, gj);
					gi *= g; gj /= g;
				} while (g != 1);
				// i 側と j 側に戻していく
				m[i] *= gi; m[j] *= gj;
				// m[i] と m[j] が元より小さくなったのに合わせて余りも計算し直しておく
				b[i] %= m[i]; b[j] %= m[j];
			}
		}
		var bb = new List<long>();
		var mm = new List<long>();
		for (int i = 0; i < b.Length; i++)
		{
			if(1<m[i]){
				bb.Add(b[i]);
				mm.Add(m[i]);
			}
		}
		b = bb.ToArray();
		m = mm.ToArray();
		long lcm = 1;
		for (int i = 0; i < b.Length; ++i) lcm = (lcm * m[i]) % MOD;
		return lcm;
	}

	public static long GCD(long a, long b) {
		while (b != 0) { var t = b; b = a % b; a = t; }
		return a;
	}
	public static long GCD(params long[] z) { long v = z[0]; for(int i=1;i<z.Length;i++) v = GCD(v, z[i]); return v; }

	public static long LCM(long a, long b) => checked(a / GCD(a, b) * b);
	public static long LCM(params long[] z) { long v = z[0]; try{ for(int i=1;i<z.Length;i++) v = LCM(v, z[i]); }catch{ v=long.MaxValue; } return v; }

	
	// 拡張ユークリッドの互除法   返り値: a と b の最大公約数  ax + by = gcd(a, b) を満たす (x, y) が格納される
	public static long EGCD(long a, long b, out long x, out long y) {
		x = 0; y = 1;
		long u = 1 , v = 0, gcd = 0;
		while (a != 0) {
			var q = b / a; var r = b % a; var m = x - u * q; var n = y - v * q;
			b = a; a = r; x = u; y = v; u = m; v = n; gcd = b;
		}
		return gcd;
	}

	// 逆元
	public static long ModInv(long value, long modulo) {
		long x, y;
		if (1 != EGCD(value, modulo, out x, out y)) throw new ArgumentException("Invalid modulo", "modulo");
		return (x < 0)?x+modulo:x;
	}







}


















#region MyIO

public struct VT<T, U>
{
	public T Item1; public U Item2;
    public VT(T a, U b) { Item1 = a; Item2 = b; }
}
public struct VT<T, U, V>
{
	public T Item1; public U Item2; public V Item3;
    public VT(T a, U b, V c) { Item1 = a; Item2 = b; Item3 = c; }
}
public struct VT<T, U, V, W>
{
	public T Item1; public U Item2; public V Item3; public W Item4;
    public VT(T a, U b, V c, W d) { Item1 = a; Item2 = b; Item3 = c; Item4 = d; }
}

public static class MyIO
{
	public class Printer : System.IO.StreamWriter
	{
		public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
		public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
		public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
	}

	private static char[] splitter = new char[] {' '};
	private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
	private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
	private static T cv<T>(string s) =>
		eq<T, int>()    ? ct<T, int>(int.Parse(s))
	  : eq<T, long>()   ? ct<T, long>(long.Parse(s))
	  : eq<T, double>() ? ct<T, double>(double.Parse(s, System.Globalization.CultureInfo.InvariantCulture))
	  : eq<T, char>()   ? ct<T, char>(s[0])
						: ct<T, string>(s);
			
	public static string[] ReadMulti<T>(out T a) {
		var ar = Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries); 
		a = cv<T>(ar[0]);
		return ar;
	}
	public static string[] ReadMulti<T, U>(out T a, out U b) {
		var ar = ReadMulti<T>(out a); 
        b = cv<U>(ar[1]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
		var ar = ReadMulti<T, U>(out a, out b); 
        c = cv<V>(ar[2]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c, out W d) {
		var ar = ReadMulti<T, U, V>(out a, out b, out c); 
        d = cv<W>(ar[3]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
		var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d); 
        e = cv<X>(ar[4]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) {
		var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e); 
        f = cv<Y>(ar[5]);
		return ar;
	}
	public static string[] ReadArray<T>(out T[] a) {		
		var ar = Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries);
		a = ar.Select(cv<T>).ToArray();
		return ar;
	}		
	public static string[][] ReadLines<T>(long n, out T[] a) {
		a = new T[n];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) arr[i] = ReadMulti(out a[i]);
		return arr;
	}
	public static string[][] ReadLines<T, U>(long n, out VT<T, U>[] a) {
		a = new VT<T, U>[n];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) {
			T o; U p;
			arr[i] = ReadMulti(out o, out p);
			a[i] = new VT<T, U>(o, p);
		}
		return arr;
	}
	public static string[][] ReadLines<T, U, V>(long n, out VT<T, U, V>[] a) {
		a = new VT<T, U, V>[n];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) {
			T o; U p; V q;
			arr[i] = ReadMulti(out o, out p, out q);
			a[i] = new VT<T, U, V>(o, p, q);
		}
		return arr;
	}
	public static string[][] ReadLines<T, U, V, W>(long n, out VT<T, U, V, W>[] a) {
		a = new VT<T, U, V, W>[n];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) {
			T o; U p; V q; W r;
			arr[i] = ReadMulti(out o, out p, out q, out r);
			a[i] = new VT<T, U, V, W>(o, p, q, r);
		}
		return arr;
	}
	public static string[][] ReadMatrix<T>(long n, out T[][] a) {
		a = new T[n][];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) arr[i] = ReadArray(out a[i]);
		return arr;
	}

	private static void wwp(Action act){
		var sw = new Printer(Console.OpenStandardOutput()){AutoFlush = false};
		Console.SetOut(sw);
		act();
		Console.Out.Flush();
		sw.AutoFlush = true;
		Console.SetOut(sw);
	}
	private static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
	public static void WriteMulti(params object[] a) {
		wwp(()=>{
			for(int i=0;i<a.Length;i++) {
				string fs = wfm(a[i].GetType()) + ((i<a.Length-1) ? " " : Environment.NewLine);
				Console.Write(fs, a[i]);
			}
		});
	}
	public static void WriteArray<T>(T[] a) {
		wwp(()=>{
			string fs = wfm(typeof(T));
			string fs1 = fs + " ";
			string fs2 = fs + Environment.NewLine;
			for(int i=0;i<a.Length;i++) Console.Write( ((i<a.Length-1) ? fs1 : fs2), a[i]);
		});
	}
	public static void WriteLines<T>(T[] a) {
		wwp(()=>{
			string fs = wfm(typeof(T)) + Environment.NewLine;
			foreach(T x in a) Console.Write(fs, x);
		});
	}


}

#endregion



Measured memory_bytes: 74632