let _ = Int(readLine()!)!
let LN = readLine()!.split(separator: " ").compactMap { Int($0) }.sorted()

var result = 0
for i in 0..<LN.count {
    let c = LN[LN.count - 1 - i]

    for j in (i+1)..<LN.count {
        let b = LN[LN.count - 1 - j]

        for z in (j+1)..<LN.count {
            let a = LN[LN.count - 1 - z]

            if a != b, b != c, a + b > c {
                result += 1
            }
        }
    }
}

print(result)
