let _ = readLine()
let inputs: Array<Int> = readInts()
let nums = Dictionary<Int, Int> { dic in
    // O(n^2)
    for i in inputs {
        dic[i] = inputs.filter({ $0 == i }).count
    }
}
let ls = Array(nums.keys).sorted()


var result = 0

for ai in ls.indices.reversed() {
    let a = ls[ai]
    let ac = nums[a]
    for bi in ls[..<ai].indices.reversed() {
        let b = ls[bi]
        let bc = nums[b]
        for ci in ls[..<bi].indices.reversed() {
            let c = ls[ci]
            let cc = nums[c]
            
            if b + c > a {
                result += ac! * bc! * cc!
            }
        }
    }
}

print(result)



// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}

extension Dictionary {
    init(_ initialize: (inout Self) -> ()) {
        var dictionary = Self()
        initialize(&dictionary)
        self = dictionary
    }
}
