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]++;
		}
  
		FastFourierTransform ntt = new FastFourierTransform();
		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 FastFourierTransform {
	public struct Complex{
		public double Re; public double Im;
		public Complex(double r, double i) { Re = r; Im = i; }
		//public decimal Re; public decimal Im;
		//public Complex(decimal r, decimal i) { Re = r; Im = i; }
		static public Complex Add(Complex a, Complex b) { return new Complex(a.Re+b.Re, a.Im+b.Im); }
		static public Complex Sub(Complex a, Complex b) { return new Complex(a.Re-b.Re, a.Im-b.Im); }
		static public Complex Mul(Complex a, Complex b) { return new Complex(a.Re*b.Re-a.Im*b.Im, a.Re*b.Im+a.Im*b.Re); }
		public Complex Conj() { return new Complex(Re, -Im); }
	}

	public class MathD {
		public const decimal PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679m;
		public const decimal E  = 2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274m;
		private const decimal EPS = 0.000000000000000000000000001m;
		// Sin(1) = 0.841470984807896506652502321630298999622563060798371065672751709991910404391239668948639743543052695
		public static decimal Sqrt(decimal x, decimal epsilon = 0.0M) {
			if (x < 0) throw new OverflowException("Cannot calculate square root from a negative number");
			decimal cur = (decimal)Math.Sqrt((double)x), prev;
			do {
				prev = cur;
				if (prev == 0.0M) return 0;
				cur = (prev + x / prev) / 2;
			}
			while (Math.Abs(prev - cur) > epsilon);
			return cur;
		}

		public static decimal Sin(decimal x) {
			if (x==0m) { return 0m; }
			if (x<0m) { return -Sin(-x); }
			if (x>PI) { return -Sin(x-PI); }
			if (x>PI*0.25m) { return Cos(PI*0.5m-x); }
			decimal x2=x*x;
			return x*(x2/6m*(x2/20m*(x2/42m*(x2/72m*(x2/110m*(x2/156m*(x2/210m*(x2/272m*(x2/342m*(x2/420m*(x2/506m*(x2/600m*(x2/702m*(x2/812m-1m)+1m)-1m)+1m)-1m)+1m)-1m)+1m)-1m)+1m)-1m)+1m)-1m)+1m);
		}
		public static decimal Cos(decimal x) {
			if (x==0m) { return 1m; }
			if (x<0m) { return Cos(-x); }
			if (x>PI) { return -Cos(x-PI); }
			if (x>PI*0.25m) { return Sin(PI*0.5m-x); }
			decimal x2=x*x;
			return (x2/2m*(x2/12m*(x2/30m*(x2/56m*(x2/90m*(x2/132m*(x2/182m*(x2/240m*(x2/306m*(x2/380m*(x2/462m*(x2/552m*(x2/650m*(x2/756m-1m)+1m)-1m)+1m)-1m)+1m)-1m)+1m)-1m)+1m)-1m)+1m)-1m)+1m);
		}
		public static decimal Tan(decimal x) => Sin(x)/Cos(x);

		public static decimal Log(double x) {
			if (x<=0.0) throw new ArgumentException("Invalid x","x");

			long bits = BitConverter.ToInt64( BitConverter.GetBytes( x ), 0 );
			x = BitConverter.ToDouble( BitConverter.GetBytes((bits & 0x000fffffffffffff)|0x3ff0000000000000), 0 );
			long scale = ((bits>>52)&0x7ff)-0x3ff;
			if(1.4142135623730950488016887242097<=x){
				x *= 0.5;
				scale++; 
			}

			decimal x1  = ((decimal)x - 1.0m) / ((decimal)x + 1.0m);
			decimal x2 = x1 * x1;
			decimal dfL = x1*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(x2*(+2m/39m)+2m/37m)+2m/35m)+2m/33m)+2m/31m)+2m/29m)+2m/27m)+2m/25m)+2m/23m)+2m/21m)+2m/19m)+2m/17m)+2m/15m)+2m/13m)+2m/11m)+2m/9m)+2m/7m)+2m/5m)+2m/3m)+2m);

			return dfL + 0.69314718055994530941723212145818m*(decimal)scale;	// log(x) = log(m) + e*log(2)  : sqrt(2)/2<=m<sqrt(2)
		}
		public static decimal Log(double x, double b) => Log(x)/Log(b);


	}

	private int _bas = 1;
  	private Complex[] _rts = { new Complex(0,0), new Complex(1,0) };
 	private int[] _rev = {0, 1};
	private long _mod = long.MaxValue;

	public FastFourierTransform() {}
	public FastFourierTransform(long mod) { _mod = mod; }
	private void ensure_base(int nbase) {
		if(nbase <= _bas) return;
		Array.Resize(ref _rev, 1 << nbase);
		Array.Resize(ref _rts, 1 << nbase);
		for(int i = 0; i < (1 << nbase); i++) _rev[i] = (_rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
		while(_bas < nbase) {
			double angle = Math.PI * 2.0 / (1 << (_bas + 1));
			//decimal angle = MathD.PI * 2.0m / (1 << (_bas + 1));
			//decimal ch = MathD.Cos(angle*2.0m), c1=0m, c2=0m, c3=0m, s1=0m, s2=0m, s3=0m;
			for(int i = 1 << (_bas - 1); i < (1 << _bas); i++) {
				_rts[i << 1] = _rts[i];
				var angle_i = angle * (2 * i + 1 - (1 << _bas));
				_rts[(i << 1) + 1] = new Complex(Math.Cos(angle_i), Math.Sin(angle_i));
				//_rts[(i << 1) + 1] = new Complex(MathD.Cos(angle_i), MathD.Sin(angle_i));

				//if((i - (1 << (_bas - 1)))%1000==0) { c1 = MathD.Cos(angle_i); s1 = MathD.Sin(angle_i); c3 = c1; s3 = s1; }
				//else if((i - (1 << (_bas - 1)))%1000==1) { c2 = MathD.Cos(angle_i); s2 = MathD.Sin(angle_i); c3 = c2; s3 = s2; }
				//else { c3 = 2.0m*ch*c2-c1; s3 = 2.0m*ch*s2-s1; c1 = c2; c2 = c3; s1 = s2; s2 = s3; }
				//_rts[(i << 1) + 1] = new Complex(c3, s3);
			}
			++_bas;
		}
	}

	private void FFT(Complex[] a, int n) {
		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 = a[j]; a[j] = a[i]; a[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 = Complex.Mul(a[i + j + k], _rts[j + k]);
					a[i + j + k] = Complex.Sub(a[i + j], z);
					a[i + j] = Complex.Add(a[i + j], z);
				}
			}
		}
	}

	// double型で計算したい場合は関数内の long を double に書き換え
	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 fa = new Complex[sz];
		for(int i = 0; i < sz; i++) fa[i] = new Complex((i < a.Length ? a[i] : 0) , (i < b.Length ? b[i] : 0));
		FFT(fa, sz);
		Complex r = new Complex(0, (-0.25 / (sz >> 1))) , s = new Complex(0, 1) , t = new Complex(0.5, 0);
		//Complex r = new Complex(0, (-0.25m / (sz >> 1))) , s = new Complex(0, 1) , t = new Complex(0.5m, 0);
		for(int i = 0; i <= (sz >> 1); i++) {
			int j = (sz - i) & (sz - 1);
			var z = Complex.Mul(  Complex.Sub( Complex.Mul(fa[j] , fa[j]) , Complex.Mul(fa[i] , fa[i]).Conj() ) , r);
			fa[j] = Complex.Mul(  Complex.Sub( Complex.Mul(fa[i] , fa[i]) , Complex.Mul(fa[j] , fa[j]).Conj() ) , r);
			fa[i] = z;
		}
		for(int i = 0; i < (sz >> 1); i++) {
			var A0 = Complex.Mul( Complex.Add(fa[i] , fa[i + (sz >> 1)]) , t);
			var A1 = Complex.Mul( Complex.Mul( Complex.Sub(fa[i] , fa[i + (sz >> 1)]) , t ) , _rts[(sz >> 1) + i] );
			fa[i] = Complex.Add( A0 , Complex.Mul(A1 , s) );
		}
		FFT(fa, sz >> 1);
		var ret = new long[need];
		for(int i = 0; i < need; i++) {
//			ret[i] = Convert.ToInt64(((i & 1) == 1)? fa[i >> 1].Im : fa[i >> 1].Re);		// 剰余無し整数
			ret[i] = Convert.ToInt64((((i & 1) == 1)? fa[i >> 1].Im : fa[i >> 1].Re)%_mod);	// 剰余有り整数
//			ret[i] = ((i & 1) == 1)? fa[i >> 1].Im : fa[i >> 1].Re;							// 実数
		}
		return ret;
	}
}





}


















#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: 54168