import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val _A = Array.fill[Int](N+1)(Int.MaxValue)
  for (i <- 1 to N) {
    _A(i) = in.next().toInt
  }

  //
  val A = _A.sorted.reverse

  val accs = new Array[Long](N+1)
  accs(1) = A(1)
  for (i <- 2 to N)
    accs(i) = A(i) + A(i-1)

  // 条件を満たす最大の値を返す
  def bs(_min: Int, _max: Int, i: Int, m: Int): Int = {
    def check(t: Int): Boolean = {
      A(t) + A(i) >= m
    }

    def func(min: Int, max: Int): Int = {
      val mid: Int = (max + min) / 2;
      (max - min) match {
        case 0 | 1 =>
          check(max) match {
            case true  => max
            case false => min
          }
        case _ =>
          (check(mid)) match {
            case true  => func(mid, max)
            case false => func(min, mid)
          }
      }
    }

    func(_min, _max)
  }

  // 条件を満たす最大の値を返す
  def binarySearch(_min: Int, _max: Int): Int = {
    def check(m: Int): Boolean = {
      var res = 0
      for (i <- 1 to N) {
        val b = bs(0, N, i, m)
        res += b
      }
      res >= M
    }

    def func(min: Int, max: Int): Int = {
      val mid: Int = (max + min) / 2;
      (max - min) match {
        case 0 | 1 =>
          check(max) match {
            case true  => max
            case false => min
          }
        case _ =>
          (check(mid)) match {
            case true  => func(mid, max)
            case false => func(min, mid)
          }
      }
    }

    func(_min, _max)
  }

  val maxPair = binarySearch(1, 1e5.toInt * 2)
  var ans = 0L
  for (i <- 1 to N) {
    val ind = bs(0, N, i, maxPair)
    ans += accs(ind) + A(i) * ind
  }
  
  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
