fun main(args: Array<String>) {
    val (N, M) = listOfLong()
    val A = listOfLong().sorted()
    val n = N.toInt()

    var L = 0
    var r = 3e5.toInt()
    while (r > L + 1) {
        var j = n
        var m = (L + r) / 2
        var cnt = 0L
        for (i in 0 until n) {
            while (j > 0 && A[i] + A[j - 1] >= m) j--
            cnt += n - j
        }
        if (cnt >= M) L = m else r = m
    }

    var j = n
    var cnt = 0L
    var sum = 0L
    var sumR = 0L
    for (i in 0 until n) {
        while (j > 0 && A[i] + A[j - 1] >= L) {
            j--
            sumR += A[j]
        }
        cnt += n - j
        sum += (n - j) * A[i] + sumR
    }
    sum -= (cnt - M) * L

    println(sum)
}
fun next() = readLine()!!
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)