import Foundation
class Inputer {
    var buffer: String
    var items: [String]
    var cnt: Int
    init() {
        buffer = ""
        var s: String? = readLine()
        while (s != nil) {
            buffer = (buffer.characters.count > 0 ? buffer + " " : "") + s!
            s = readLine()
        }
        cnt = 0
        items = buffer.characters.split{$0 == " "}.map(String.init)
    }
    func getInt() -> Int {
        let str = String(items[cnt])
        cnt += 1
        return Int(str)!
    }
    func getIntArray(t: Int) -> [Int] {
        var r = [Int](count: t, repeatedValue: 0)
        for n in 0..<t { r[n] = getInt() }
        return r
    }
    func getStr() -> String {
        let str = String(items[cnt])
        cnt += 1
        return str
    }
    func getStrArray(t: Int) -> [String] {
        var r = [String](count: t, repeatedValue: "")
        for n in 0..<t { r[n] = getStr() }
        return r
    }
}

let cin = Inputer()
let N = cin.getInt()
var L = cin.getIntArray(N)
L.sortInPlace()
var ans = 0

for i in 0 ..< N-2 {
    let a = L[i]
    for j in i+1 ..< N-1 {
        let b = L[j]
        if (a > b) { }
        else {
            for k in j+1 ..< N {
                let c = L[k]
                if (a < b + c && b < c + a && c < a + b) { ans += 1 }
            }
        }
    }
}

print(ans)
