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 static void Main() {
		Solve_E();
 	}

	public static void Solve_A() {
        int n;
		VT<int,int>[] p;
		MyIO.ReadMulti(out n);
		MyIO.ReadLines(n, out p);
 
		ll[] a = new ll[n+1];
		ll[] b = new ll[n+1];
 
		for (int i = 0; i < n;i++)	{
			a[i+1] = p[i].Item1;
			b[i+1] = p[i].Item2;
		}
		
		FastFourierTransform ntt = new FastFourierTransform();
		ll[] c = ntt.Multiply(a,b);
 
 
 
 
		MyIO.WriteLines(c.Skip(1).Take(2*n).ToArray());
	}
	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 fft = new FastFourierTransform();
		ll[] b = fft.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 FastFourierTransform2
{
	public struct Complex{
		public double Re; public double Im;
		public Complex(double r, double 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 FastFourierTransform2() { }
 
	// 精度は 2^51 (15桁) 程度まで
    public long[] Multiply(long[] A, long[] B)
    {
		double[] da = new double[A.Length];
		double[] db = new double[B.Length];
		for (int i = 0; i < A.Length; i++) da[i] = A[i];
		for (int i = 0; i < B.Length; i++) db[i] = B[i];
		double[] cc = Multiply(da,db);
		long[] lc = new long[cc.Length];
		for (int i = 0; i < cc.Length; i++) lc[i] = (long)Math.Round(cc[i]);
		return lc;
	}
    public double[] Multiply(double[] A, double[] B)
    {
        int sz = A.Length + B.Length - 1;
        int N = 1; while (N < sz) N <<= 1;
 
        Complex[] G = new Complex[N];
        Complex[] H = new Complex[N];
        for (int i = 0; i < A.Length; i++) G[i] = new Complex(A[i],0);
        for (int i = 0; i < B.Length; i++) H[i] = new Complex(B[i],0);
 
        FFT(G, false); FFT(H, false);
        Complex[] F = new Complex[N];
        for (int i = 0; i < N; i++)F[i] = Complex.Mul(G[i], H[i]);
 
        FFT(F, true);
        double[] I = new double[N];
        for (int i = 0; i < N; i++)I[i] = F[i].Re;

        return I;
    }
    private void FFT(Complex[] F, bool rev)
    {
		int irev = rev?-1:1;
        for (int i = 0, j = 1; j < F.Length - 1; j++) {
            for (int k = F.Length >> 1; k > (i ^= k); k >>= 1) ;
            if (j < i) swap(ref F[i], ref F[j]);
        }
 
        for (int i = 2; i <= F.Length; i <<= 1) {
            int m = i >> 1;
			Complex[] zp = new Complex[F.Length];
			for (int j = 0; j < F.Length; j++) zp[j] = new Complex(Math.Cos(Math.PI / m * j), Math.Sin(Math.PI / m * j) * irev);
 
            for (int j = 0; j < F.Length; j += i) {
                for (int u = j, v = j + m; v < j + i; u++, v++) {
                    Complex vl = F[u], vr = Complex.Mul(zp[u-j], F[v]);
                    F[u] = Complex.Add(vl, vr);
                    F[v] = Complex.Sub(vl, vr);
                }
            }
        }
 
        if (rev) {
            for (int i = 0; i < F.Length; i++) F[i] = new Complex(F[i].Re/F.Length, F[i].Im/F.Length);
        }
    }
     private void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; }
}


public class FastFourierTransform {
	public struct Complex{
		public double Re; public double Im;
		public Complex(double r, double 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); }
	}

	private int bas = 1;
  	private Complex[] rts = new Complex[2]{ new Complex(0,0), new Complex(1,0) };
 	private int[] rev = {0, 1};

    private void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; }

	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));
			for(int i = 1 << (bas - 1); i < (1 << bas); i++) {
				rts[i << 1] = rts[i];
				double angle_i = angle * (2 * i + 1 - (1 << bas));
				rts[(i << 1) + 1] = new Complex(Math.Cos(angle_i), Math.Sin(angle_i));
			}
			++bas;
		}
	}

	private void FFT(Complex[] a, int n) {
		if ((n & (n - 1)) != 0) throw new ArgumentException("Invalid size", "size");
		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++) {
			if(i < (rev[i] >> shift)) {
				swap(ref a[i], ref a[rev[i] >> shift]);
			}
		}
		for(int k = 1; k < n; k <<= 1) {
			for(int i = 0; i < n; i += 2 * k) {
				for(int j = 0; j < k; j++) {
					Complex 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);
				}
			}
		}
	}

	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;
		Complex[] fa = new Complex[sz];
		for(int i = 0; i < sz; i++) {
			long x = (i < a.Length ? a[i] : 0);
			long y = (i < b.Length ? b[i] : 0);
			fa[i] = new Complex(x, y);
		}
		FFT(fa, sz);
		Complex r = new Complex(0, -0.25 / (sz >> 1));
		Complex s = new Complex(0, 1);
		Complex t = new Complex(0.5, 0);
		for(int i = 0; i <= (sz >> 1); i++) {
			int j = (sz - i) & (sz - 1);
			Complex 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++) {
			Complex A0 = Complex.Mul( Complex.Add(fa[i] , fa[i + (sz >> 1)]) , t);
			Complex 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);
		long[] ret = new long[need];
		for(int i = 0; i < need; i++) {
			ret[i] = (long)Math.Round(((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 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) { }
}
public static class MyIO
{
	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: 35548