import kotlin.math.max

fun main() {
    val n = nextInt()
    val ln = nextIntList()
    val ans = solve(ln)
    println(ans)
}


fun solve(ln: List<Int>): Int {
    val excludeDistinctLn = ln.distinct()
    val excludeDistinctLnSize = excludeDistinctLn.size

    if (excludeDistinctLnSize < 3) return 0

    var max = 0
    val lnMap = ln.groupBy { it }

    for (i in 0..excludeDistinctLnSize - 1) {
        val li = excludeDistinctLn[i]
        for (j in (i +1)..excludeDistinctLnSize - 1) {
            val lj = excludeDistinctLn[j]
            for (k in (j + 1)..excludeDistinctLnSize - 1) {

                val lk = excludeDistinctLn[k]
                if (li + lj - lk > 0 && li + lk - lj > 0 && lk + lj - li > 0) {
                    max += lnMap[li]!!.size * lnMap[lj]!!.size * lnMap[lk]!!.size
                }
            }
        }
    }

    return max
}

fun nextInt(): Int {
    return readLine()!!.toInt()
}

fun nextIntList(): List<Int> {
    return readLine()!!.split(" ").map { it.toInt() }
}

fun nextString(): String {
    return readLine()!!
}