using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			long m = cin.Long();
			long[] a = cin.ArrayLong(n);
			Array.Sort(a);

			long target = m;
			long left = -1;
			long right = a[n - 1] * 2;
			int[] indexes = new int[n];
			long num = 0;
			while (right - left > 1) {
				long mid = (right + left) / 2;

				num = Search(n, a, mid, indexes);

				if (num < target) {
					right = mid;
				} else {
					left = mid;
				}
			}

			num = Search(n, a, left, indexes);

			long[] sums = new long[n];
			sums[0] = a[0];
			for (int i = 1; i < n; i++) {
				sums[i] = a[i] + sums[i - 1];
			}

			long ans = 0;
			for (int i = 0; i < n; i++) {
				int count = indexes[i];
				long temp = count == n 
					? sums[n - 1]
					: sums[n - 1] - sums[n - 1 - count];
				temp += a[i] * count;

				ans += temp;
			}

			if (num > target) {
				long min = long.MaxValue;
				for (int i = 0; i < n; i++) {
					if (indexes[i] > 0) {
						min = Math.Min(min, a[i] + a[n - indexes[i]]);
					}
				}

				if (min != long.MaxValue) {
					ans -= min * (num - target);
				}
			}

			Console.WriteLine(ans);
		}

		public static long Search(int n, long[] a, long target, int[] indexes) 
		{
			long count = 0;
			for (int i = 0; i < n; i++) {
				int left = -1;
				int right = n;

				while (right - left > 1) {
					int mid = (right + left) / 2;
					long temp = a[mid] + a[i];
					if (temp >= target) {
						right = mid;
					} else {
						left = mid;
					}
				}

				indexes[i] = n - right;
				count += indexes[i];
			}

			return count;
		}

		public static int LowerBound(IReadOnlyList<long> list, long target)
		{
			int left = -1;
			int right = list.Count();

			while (right - left > 1) {
				int mid = (right + left) / 2;

				if (list[mid] >= target) {
					right = mid;
				} else {
					left = mid;
				}
			}

			return right;
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 20704