import sys

input = sys.stdin.readline





def main():

    n = int(eval(input()))

    L = list(map(int, input().split()))

    L.sort()

    ans = 0

    for i in range(n-2):

        for j in range(i, n-1):

            for k in range(j, n):

                if L[k] < L[j] + L[i] and len({L[i], L[j], L[k]}) == 3:

                    ans += 1

    print(ans)





if __name__ == "__main__":

    main()

from collections import Counter

from bisect import bisect_left

import sys

input = sys.stdin.readline





def main():

    _ = int(eval(input()))

    L = list(map(int, input().split()))

    counter = Counter(L)

    L = list(set(L))

    L.sort()

    n = len(L)

    

    cumsum = []

    total = 0

    for l in L:

        total += counter[l]

        cumsum.append(total)





    ans = 0

    for i in range(n-2):

        for j in range(i+1, n-1):

            a, b = L[i], L[j]

            limit = a + b

            k = bisect_left(L, limit, lo=j+1)

            pattern = counter[a] * counter[b] * (cumsum[k-1] - cumsum[j])

            ans += pattern



    print(ans)





if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for i in range(n - 2):
        for j in range(i, n - 1):
            for k in range(j, n):
                if L[k] < L[j] + L[i] and len({L[i], L[j], L[k]}) == 3:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()

from collections import Counter
from bisect import bisect_left
import sys

input = sys.stdin.readline


def main():
    _ = int(eval(input()))
    L = list(map(int, input().split()))
    counter = Counter(L)
    L = list(set(L))
    L.sort()
    n = len(L)
    cumsum = []
    total = 0
    for l in L:
        total += counter[l]
        cumsum.append(total)
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            a, b = L[i], L[j]
            limit = a + b
            k = bisect_left(L, limit, lo=j + 1)
            pattern = counter[a] * counter[b] * (cumsum[k - 1] - cumsum[j])
            ans += pattern
    print(ans)


if __name__ == "__main__":
    main()

+from collections import Counter +from bisect import bisect_left -    n = int(eval(input())) +    _ = int(eval(input())) +    counter = Counter(L) +    L = list(set(L)) +    n = len(L) +    cumsum = [] +    total = 0 +    for l in L: +        total += counter[l] +        cumsum.append(total) -        for j in range(i, n - 1): -            for k in range(j, n): -                if L[k] < L[j] + L[i] and len({L[i], L[j], L[k]}) == 3: -                    ans += 1 +        for j in range(i + 1, n - 1): +            a, b = L[i], L[j] +            limit = a + b +            k = bisect_left(L, limit, lo=j + 1) +            pattern = counter[a] * counter[b] * (cumsum[k - 1] - cumsum[j]) +            ans += pattern