import sys

import bisect





def input():

    return sys.stdin.readline().rstrip()





def main():

    N = int(eval(input()))

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



    L.sort()

    count = 0



    for j in range(1, N - 1):

        for i in range(j):

            if L[i] == L[j]:

                break

            a = bisect.bisect_right(L[j + 1:], L[j])

            b = bisect.bisect_left(L[j + 1:], L[i] + L[j])

            count += b - a



    print(count)





if __name__ == "__main__":

    main()

import sys





def input():

    return sys.stdin.readline().rstrip()





def main():

    N = int(eval(input()))

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



    L.sort()

    count = 0

    for j in range(1, N - 1):

        for i in range(j):

            if L[i] == L[j]:

                break

            t = L[i] + L[j]

            for k in range(j + 1, N):

                if L[j] != L[k]:

                    if t > L[k]:

                        count += 1

                    else:

                        break



    print(count)





if __name__ == "__main__":

    main()

import sys
import bisect


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(eval(input()))
    L = list(map(int, input().split()))
    L.sort()
    count = 0
    for j in range(1, N - 1):
        for i in range(j):
            if L[i] == L[j]:
                break
            a = bisect.bisect_right(L[j + 1 :], L[j])
            b = bisect.bisect_left(L[j + 1 :], L[i] + L[j])
            count += b - a
    print(count)


if __name__ == "__main__":
    main()

import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(eval(input()))
    L = list(map(int, input().split()))
    L.sort()
    count = 0
    for j in range(1, N - 1):
        for i in range(j):
            if L[i] == L[j]:
                break
            t = L[i] + L[j]
            for k in range(j + 1, N):
                if L[j] != L[k]:
                    if t > L[k]:
                        count += 1
                    else:
                        break
    print(count)


if __name__ == "__main__":
    main()

-import bisect -            a = bisect.bisect_right(L[j + 1 :], L[j]) -            b = bisect.bisect_left(L[j + 1 :], L[i] + L[j]) -            count += b - a +            t = L[i] + L[j] +            for k in range(j + 1, N): +                if L[j] != L[k]: +                    if t > L[k]: +                        count += 1 +                    else: +                        break