func main() {
    let n = Int(readLine()!)!
    if n < 3 {
        print(0)
        return
    }
    let lList = readLine()!.split(separator: " ").map{Int($0)!}.sorted()
    var count = 0
    for i in 1...n-2 {
        let a = lList[i-1]
        for j in i+1...n-1 {
            let b = lList[j-1]
            if a == b { continue }
            for k in j+1...n {
                let c = lList[k-1]
                if b == c { continue }
                if c < a + b {
                    count += 1
                }
            }
        }
    }
    print(count)
    return
}

main()
