AtCoder Beginner Contest 175 - Making Triangle

We have sticks numbered 1, \cdots, N. The length of Stick i (1 \leq i \leq N) is L_i.
In how many ways can we choose three of the sticks with different lengths that can form a triangle?
That is, find the number of triples of integers (i, j, k) (1 \leq i < j < k \leq N) that satisfy both of the following conditions:
 - L_i, L_j, and L_k are all different.
 - There exists a triangle whose sides have lengths L_i, L_j, and L_k.

-----Constraints-----
 - 1 \leq N \leq 100
 - 1 \leq L_i \leq 10^9
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
L_1 L_2 \cdots L_N

-----Output-----
Print the number of ways to choose three of the sticks with different lengths that can form a triangle.

-----Sample Input-----
5
4 4 9 7 5

-----Sample Output-----
5

The following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).

Difficulty: EASY

Starter code:

Solutions:
N = int(input())
ans = 0
a = sorted(list(map(int, input().split())))
for i in range(N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			if a[i] != a[j] and a[j] != a[k] and (a[i] + a[j] > a[k]):
				ans += 1
print(ans)


n = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			cnt += L[i] + L[j] > L[k] and L[i] != L[j] != L[k]
print(cnt)


(n, *l) = map(int, open(0).read().split())
l.sort()
c = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if len({l[i], l[j], l[k]}) == 3 and l[i] + l[j] > l[k]:
				c += 1
print(c)


n = int(input())
ar = [int(x) for x in input().split()]
ar.sort()
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if ar[i] != ar[j] and ar[j] != ar[k] and (ar[i] + ar[j] > ar[k]):
				ans += 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
len_l = len(l)
ans = 0
for i in range(len_l - 2):
	for j in range(i + 1, len_l - 1):
		for k in range(j + 1, len_l):
			if l[i] != l[j] and l[i] != l[k] and (l[j] != l[k]):
				if l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and (l[j] + l[k] > l[i]):
					ans += 1
print(ans)


N = int(input())
L = sorted(list(map(int, input().split())))
ans = [1 for i in range(N - 2) for j in range(i + 1, N - 1) for k in range(j + 1, N) if L[i] != L[j] and L[j] != L[k] and (L[i] + L[j] > L[k])]
print(len(ans))


import itertools as it
N = int(input())
L = [*map(int, input().split())]
count = 0
for (a, b, c) in it.combinations(L, 3):
	if a != b != c != a and a + b > c and (b + c > a) and (c + a > b):
		count += 1
print(count)


from itertools import combinations
N = int(input())
L = list(map(int, input().split()))
cnt = 0
for (a, b, c) in combinations(L, 3):
	if a != b and b != c and (c != a):
		if a + b > c and b + c > a and (c + a > b):
			cnt += 1
print(cnt)


from itertools import *
(n, *l) = map(int, open(0).read().split())
cnt = 0
for (a, b, c) in combinations(l, 3):
	if a != b != c != a and a + b > c and (b + c > a) and (c + a > b):
		cnt += 1
print(cnt)


N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			if L[i] < L[j] < L[k] and L[k] < L[i] + L[j]:
				ans += 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
s = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if l[j] + l[i] > l[k] and l[i] != l[j] and (l[j] != l[k]):
				s += 1
print(s)


import itertools
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in itertools.combinations(L, 3):
	(x, y, z) = i
	if x == y or x == z or y == z:
		continue
	if x + y > z and x + z > y and (y + z > x):
		ans += 1
print(ans)


n = int(input(''))
s = list(map(int, input().split()))
cnt = 0
s.sort()
for i in range(0, n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if s[i] != s[j] != s[k]:
				if s[i] + s[j] > s[k]:
					cnt += 1
print(cnt)


from itertools import combinations
N = int(input())
(*L,) = map(int, input().split())
ans = 0
for (a, b, c) in combinations(L, 3):
	if a == b or b == c or a == c:
		continue
	if a + b > c and b + c > a and (a + c > b):
		ans += 1
print(ans)


n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
ed = []
for i in range(n):
	for j in range(i):
		for k in range(j):
			if l[k] != l[j] and l[i] != l[j] and (l[k] + l[j] > l[i]):
				ans += 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if l[i] + l[j] > l[k] and l[i] != l[j] and (l[j] != l[k]) and (l[i] != l[k]):
				count += 1
print(count)


from itertools import *
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for (i, j, k) in combinations(a, 3):
	if i < j < k and i + j > k:
		ans += 1
print(ans)


import itertools
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in itertools.combinations(l, 3):
	if i[0] != i[1] and i[1] != i[2] and (i[2] != i[0]):
		if sum(i) - max(i) > max(i):
			cnt += 1
print(cnt)


N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in L:
	for j in L:
		for k in L:
			if i < j < k:
				if i + j + k > max(i, j, k) * 2:
					ans += 1
else:
	print(ans)


import itertools
N = input()
L = map(int, input().split())
ans = 0
for (x, y, z) in itertools.combinations(L, 3):
	ans += x + y > z and y + z > x and (z + x > y) and (x != y) and (y != z) and (z != x)
print(ans)


N = int(input())
L_l = sorted(map(int, input().split()))
ans = 0
for i in range(N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			if L_l[i] < L_l[j] and L_l[j] < L_l[k] and (L_l[i] + L_l[j] > L_l[k]):
				ans += 1
			else:
				continue
print(ans)


from itertools import combinations
N = int(input())
L = sorted(map(int, input().split()))
c = 0
for a in combinations(L, 3):
	if a[0] == a[1] or a[0] == a[2] or a[1] == a[2]:
		continue
	if a[0] + a[1] > a[2]:
		c += 1
print(c)


import sys
readline = sys.stdin.readline
N = int(readline())
L = list(map(int, readline().split()))
L = sorted(L)
ans = 0
for i in range(N - 2):
	for j in range(i + 1, N - 1):
		for k in range(j + 1, N):
			if len(set([L[i], L[j], L[k]])) != 3:
				continue
			if L[i] + L[j] > L[k]:
				ans += 1
print(ans)


n = int(input())
l = sorted([int(x) for x in input().split()])
a = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if l[i] < l[j] < l[k] and l[i] + l[j] > l[k]:
				a += 1
print(a)


n = int(input())
l = list(map(int, input().split()))
ans = 0
for a in l:
	for b in l:
		for c in l:
			if a == b or b == c or a == c:
				continue
			if max([a, b, c]) < a + b + c - max([a, b, c]):
				ans += 1
print(ans // 6)


n = int(input())
l = list(map(int, input().split()))
ls = sorted(l)
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			(a, b, c) = (ls[i], ls[j], ls[k])
			if len(set([a, b, c])) == 3:
				if a + b > c:
					ans += 1
print(ans)


import itertools
N = int(input())
L = list(map(int, input().split()))
res = 0
for i in itertools.combinations(L, 3):
	i = list(i)
	i.sort()
	if i[0] != i[1] and i[1] != i[2]:
		if i[2] < i[0] + i[1]:
			res += 1
print(res)


N = int(input())
L = list(map(int, input().split()))
count = 0
for i in range(0, N - 2):
	for j in range(0, N - i - 2):
		for k in range(0, N - 2 - j - i):
			if L[i] != L[j + 1 + i] and L[i] != L[k + i + 2 + j] and (L[j + 1 + i] != L[k + 2 + i + j]):
				if L[i] + L[j + 1 + i] > L[k + 2 + i + j] and L[i] + L[k + 2 + i + j] > L[j + 1 + i] and (L[k + 2 + i + j] + L[j + 1 + i] > L[i]):
					count += 1
print(count)


import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp
INF = inf
MOD = 1000000007
n = int(input())
L = [int(i) for i in input().split()]
tmp = 0
res = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if L[i] != L[j] and L[j] != L[k] and (L[k] != L[i]) and (abs(L[i] - L[j]) < L[k] < L[i] + L[j]):
				res += 1
print(res)


from itertools import combinations
N = input()
L = sorted(map(int, input().split()))
print(sum((a + b > c and a != b != c != a for (a, b, c) in combinations(L, 3))))


import itertools
N = int(input())
L = list(map(int, input().split()))
count = sum([True for (a, b, c) in itertools.combinations(L, 3) if not (a == b or a == c or b == c) and (a + b > c and a + c > b and (b + c > a))])
print(count)


from itertools import combinations
N = int(input())
L = list(map(int, input().split()))
c = 0
for p in combinations(L, 3):
	p = sorted(p)
	c += len(p) == len(set(p)) and p[2] < p[0] + p[1]
print(c)


N = int(input())
L = list(map(int, input().split()))
OKs = 0
import itertools
for c in itertools.combinations(L, 3):
	if len(set(c)) == 3:
		c = sorted(list(c))
		(c1, c2) = (c[2], c[:2])
		if sum(c2) > c1:
			OKs += 1
print(OKs)


n = int(input())
a = list(map(int, input().split()))
a.sort()
score = 0
for f in range(n - 2):
	for s in range(f + 1, n - 1):
		for t in range(s + 1, n):
			if a[f] + a[s] > a[t] and a[f] != a[s] and (a[f] != a[t]) and (a[s] != a[t]):
				score += 1
print(score)


n = int(input())
l = list(map(int, input().split()))
l.sort()
s = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		s += sum([1 for k in l[j + 1:] if l[j] < k and k < l[i] + l[j]]) if l[i] < l[j] else 0
print(s)


import itertools
N = int(input())
L = list(map(int, input().split()))
count = 0
for a in itertools.combinations(L, 3):
	if len(set(a)) != 3:
		continue
	a = sorted(a)
	if a[2] < a[0] + a[1]:
		count += 1
print(count)


n = int(input())
L = list(map(int, input().split()))
count = 0
for a in range(n - 2):
	for b in range(a + 1, n - 1):
		for c in range(b + 1, n):
			if L[a] + L[b] > L[c] and L[b] + L[c] > L[a] and (L[c] + L[a] > L[b]):
				if L[a] != L[b] and L[b] != L[c] and (L[c] != L[a]):
					count += 1
print(count)


import itertools
n = int(input())
l = list(map(int, input().split()))
a = list(itertools.combinations(l, 3))
ans = 0
for i in a:
	tmp = sorted(i)
	if tmp[0] != tmp[1] != tmp[2] and tmp[0] + tmp[1] > tmp[2]:
		ans += 1
print(ans)


N = int(input())
L = [int(_) for _ in input().split()]
a = 0
import itertools
C = itertools.combinations(L, 3)
for c in C:
	if len(set(c)) != 3:
		continue
	if sum(c) > 2 * max(c):
		a += 1
print(a)


(n, *l) = map(int, open(0).read().split())
cnt = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			(a, b, c) = (l[i], l[j], l[k])
			if a == b or b == c or c == a:
				continue
			if abs(b - c) < a < b + c:
				cnt += 1
print(cnt)


n = int(input())
a = list(map(int, input().split()))
hasil = 0
a = sorted(a)
for x in range(n - 2):
	for y in range(x + 1, n - 1):
		for z in range(y + 1, n):
			if a[x] != a[y] and a[y] != a[z] and (a[z] != a[x]):
				if a[x] + a[y] > a[z]:
					hasil = hasil + 1
print(hasil)


N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N - 1, 0, -1):
	for a in range(i - 1, -1, -1):
		for b in range(a - 1, -1, -1):
			if L[i] < L[a] + L[b] and L[i] != L[a] != L[b]:
				ans += 1
print(ans)


n = int(input())
l_list = list(map(int, input().split()))
len_l = len(l_list)
l_list = sorted(l_list)
cnt = 0
for i in range(len_l - 2):
	for j in range(i + 1, len_l - 1):
		for k in range(j + 1, n):
			a = l_list[i]
			b = l_list[j]
			c = l_list[k]
			if a != b != c and a + b > c:
				cnt += 1
print(cnt)


n = int(input())
l = list(map(int, input().split()))
cnt = 0
for a in range(n - 2):
	for b in range(a + 1, n - 1):
		for c in range(b + 1, n):
			if len(set([l[a], l[b], l[c]])) == 3:
				if l[a] + l[b] > l[c] and l[b] + l[c] > l[a] and (l[c] + l[a] > l[b]):
					cnt += 1
print(cnt)


n = int(input())
l = list(map(int, input().split()))
c = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if l[i] != l[j] and l[j] != l[k] and (l[k] != l[i]) and (2 * max([l[i], l[j], l[k]]) < sum([l[i], l[j], l[k]])):
				c += 1
print(c)


def cin():
	return list(map(int, input().split()))
N = int(input())
L = cin()
count = 0
for i in range(0, N - 2):
	for j in range(1 + i, N - 1, 1):
		for k in range(1 + j, N, 1):
			data = [L[i], L[j], L[k]]
			data.sort()
			if data[0] == data[1] or data[1] == data[2] or data[2] == data[0]:
				continue
			if data[0] + data[1] > data[2]:
				count += 1
print(count)


N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
count = 0
for x in L:
	for y in L:
		for z in L:
			if x < y + z and x > y and (y > z):
				count += 1
print(count)


import itertools
n = int(input())
l = list(map(int, input().split()))
ans = 0
for (a, b, c) in itertools.combinations(l, 3):
	if abs(a - b) < c < a + b and len(set([a, b, c])) == 3:
		ans += 1
print(ans)


n = int(input())
a = sorted(list(map(int, input().split())))
c = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if a[k] < a[i] + a[j] and a[k] != a[j] and (a[j] != a[i]) and (a[i] != a[k]):
				c += 1
print(c)


import itertools
N = int(input())
L = list(map(int, input().split()))
L.sort()
Combi = itertools.combinations(L, 3)
count = 0
for (i, j, k) in Combi:
	if i + j > k and i != j != k and (i < j < k):
		count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if a[i] != a[j] and a[j] != a[k]:
				if a[i] + a[j] > a[k]:
					ans += 1
print(ans)


from itertools import combinations
n = int(input())
L = list(map(int, input().split()))
ans = 0
for x in combinations(L, 3):
	(a, b, c) = map(int, x)
	if a == b or b == c or c == a:
		continue
	ans += 2 * max(a, b, c) < a + b + c
print(ans)


N = int(input())
L = list(map(int, input().split()))
from itertools import combinations
r = 0
for (a, b, c) in combinations(L, 3):
	if a != b and b != c and (a != c) and (2 * max(a, b, c) < a + b + c):
		r += 1
print(r)


import itertools
n = int(input())
l = list(map(int, input().split()))
s = list(itertools.combinations(l, 3))
count = 0
for i in s:
	(a, b, c) = i
	if a + b > c and b + c > a and (c + a > b) and (a != b) and (b != c) and (c != a):
		count += 1
print(count)


from itertools import combinations
(N, *L) = map(int, open(0).read().split())
ans = 0
for (a, b, c) in combinations(L, 3):
	if a != b and b != c and (c != a) and (a + b > c) and (b + c > a) and (c + a > b):
		ans += 1
print(ans)


from itertools import combinations
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for (a, b, c) in combinations(L, 3):
	ans += a < b < c < a + b
print(ans)


import itertools
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for (a, b, c) in itertools.combinations(L, 3):
	if a < b < c and a + b > c:
		ans += 1
print(ans)


import itertools
input()
l = list(map(int, input().split()))
ans = 0
for (a, b, c) in itertools.combinations(l, 3):
	if a == b or b == c or c == a:
		continue
	if a + b > c and b + c > a and (c + a > b):
		ans += 1
print(ans)


from itertools import combinations as ic
N = int(input())
L = map(int, input().split())
A = list(ic(L, 3))
ans = 0
for i in A:
	if 2 * max(i) - sum(i) < 0 and len(set(i)) == 3:
		ans += 1
else:
	print(ans)


import itertools
n = int(input())
numbers = list(map(int, input().split()))

def canMakeTriangle(a, b, c):
	return a < b + c and b < a + c and (c < a + b)

def isDifferentLength(a, b, c):
	return a != b and b != c and (c != a)

def isTargetTriangle(a, b, c):
	return isDifferentLength(a, b, c) and canMakeTriangle(a, b, c)
total = 0
for (a, b, c) in list(itertools.combinations(numbers, 3)):
	if isTargetTriangle(a, b, c):
		total += 1
print(total)


n = int(input())
listL = list(map(int, input().split()))
count = 0
for l1 in listL:
	for l2 in listL:
		for l3 in listL:
			if l2 > l1 and l3 > l2 and (l1 + l2 > l3):
				count += 1
print(count)


import itertools
n = int(input())
l = list(map(int, input().split()))
ans = 0
for comb in itertools.combinations(l, 3):
	li = list(comb)
	li.sort()
	if li[2] < li[0] + li[1] and li[0] != li[1] != li[2]:
		ans += 1
print(ans)


import sys
N = int(input())
L = list(map(int, input().split()))
count = 0
for i in range(N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			a = L[i]
			b = L[j]
			c = L[k]
			if abs(b - c) < a < b + c and (a != b and a != c and (b != c)):
				count += 1
print(count)


import itertools
n = int(input())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for v in itertools.combinations(a, 3):
	(x, y, z) = (v[0], v[1], v[2])
	if x + y > z and x != y and (y != z) and (z != x):
		cnt += 1
print(cnt)


from itertools import combinations
n = int(input())
L = list(map(int, input().split()))
ans = 0
for (a, b, c) in combinations(L, 3):
	ans += (2 * max(a, b, c) < a + b + c) * (a != b and b != c and (c != a))
print(ans)


N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N - 2):
	side1 = L[i]
	for j in range(i + 1, N - 1):
		side2 = L[j]
		if side1 == side2:
			continue
		lim = side1 + side2
		for k in range(j + 1, N):
			side3 = L[k]
			if side3 >= lim:
				break
			if side3 != side2:
				ans += 1
print(ans)


import itertools
import collections
N = int(input())
Ls = list(map(int, input().split()))
L_combination = itertools.combinations(Ls, 3)
ans = 0
for sanpenList in L_combination:
	checker = set(sanpenList)
	if len(sanpenList) != len(checker):
		continue
	if max(sanpenList) * 2 >= sum(sanpenList):
		continue
	ans += 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if len(set([l[i], l[j], l[k]])) == 3 and l[i] + l[j] > l[k]:
				ans += 1
print(ans)


from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for (li, lj, lk) in combinations(l, 3):
	if li < lj < lk < li + lj:
		ans += 1
print(ans)


from itertools import combinations
N = int(input())
L = list(map(int, input().split()))
ans = 0
for lst in combinations(L, 3):
	if len(set(lst)) == 3 and max(lst) < sum(lst) - max(lst):
		ans += 1
print(ans)


n = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			a = L[i]
			b = L[j]
			c = L[k]
			A = [a, b, c]
			if a == b or b == c or c == a:
				continue
			if sum(A) - 2 * max(A) > 0:
				ans += 1
print(ans)


import itertools
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for (a, b, c) in itertools.combinations(l, 3):
	if a != b and b != c and (c != a) and (abs(b - c) < a) and (a < b + c):
		cnt += 1
print(cnt)


from itertools import combinations
n = int(input())
A = list(map(int, input().split()))
count = 0
for i in combinations(A, 3):
	i = sorted(i)
	if len(set(i)) == 3 and i[0] + i[1] > i[2]:
		count += 1
print(count)


import itertools
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for x in itertools.combinations(l, 3):
	if x[0] != x[1] and x[1] != x[2] and (x[2] != x[0]):
		x = sorted(x)
		if x[0] + x[1] > x[2]:
			cnt += 1
print(cnt)


from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
ans = 0
for (i, j, k) in combinations(l, 3):
	if i == j or i == k or j == k:
		continue
	if i >= j + k or j >= i + k or k >= i + j:
		continue
	ans += 1
print(ans)


n = int(input())
l = [int(s) for s in input().split()]
l.sort(key=int)
count = 0
for i in range(len(l)):
	for j in range(i + 1, len(l)):
		for t in range(j + 1, len(l)):
			if l[i] + l[j] > l[t] and l[i] != l[j] != l[t]:
				count += 1
print(count)


N = int(input())
A = [int(x) for x in input().split()]
A.sort()
score = 0
for i in range(N):
	for j in range(i, N):
		for k in range(j, N):
			if A[i] != A[j] and A[j] != A[k] and (A[i] + A[j] > A[k]):
				score += 1
print(score)


def main():
	N = int(input())
	a = list(map(int, input().split()))
	a.sort()
	cnt = 0
	for i in range(N - 2):
		for j in range(i + 1, N - 1):
			if a[i] == a[j]:
				continue
			for k in range(j + 1, N):
				if a[i] == a[k] or a[j] == a[k]:
					continue
				if a[k] < a[i] + a[j]:
					cnt += 1
	print(cnt)

def __starting_point():
	main()
__starting_point()


n = int(input())
L = list(map(int, input().split()))
print(sum((i < j < k < i + j for i in L for j in L for k in L)))


N = int(input())
L = list(map(int, input().split()))
p = 0
for i in range(0, N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			if L[i] + L[j] > L[k] and L[k] + L[i] > L[j] and (L[j] + L[k] > L[i]) and (L[i] != L[j] != L[k] != L[i]):
				p += 1
			else:
				pass
print(p)


import itertools
N = int(input())
L = list(map(int, input().split()))
result = 0
for c in itertools.combinations(L, 3):
	if len(set(c)) == 3:
		s = sorted(c)
		if s[0] + s[1] > s[2]:
			result += 1
print(result)


n = int(input())
b = list(map(int, input().split()))
x = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if b[i] != b[j] and b[j] != b[k] and (b[k] != b[i]):
				if b[i] < b[j] + b[k] and b[j] < b[i] + b[k] and (b[k] < b[i] + b[j]):
					x += 1
print(x)


import itertools
N = int(input())
a = list(map(int, input().split()))
a_ = list(itertools.combinations(a, 3))
count = 0
for i in a_:
	if len(set(i)) == 3:
		if i[0] + i[1] > i[2] and i[0] + i[2] > i[1] and (i[1] + i[2] > i[0]):
			count = count + 1
print(count)


n = int(input())
lis = list(map(int, input().split()))
a = 0
b = 0
c = 0
output = 0
for i in range(len(lis)):
	a = lis[i]
	for j in range(i + 1, len(lis)):
		b = lis[j]
		for k in range(j + 1, len(lis)):
			c = lis[k]
			if a + b > c and a + c > b and (b + c > a) and (a != b and b != c and (c != a)):
				output += 1
print(output)


from itertools import combinations
n = int(input())
arr = list(map(int, input().split()))
res = 0
for c in combinations(arr, 3):
	if len(set(c)) < 3:
		continue
	if max(c) < sum(c) - max(c):
		res += 1
print(res)


from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
ans = 0
for c in combinations(l, 3):
	if len(set(c)) == 3 and sum(c) - max(c) > max(c):
		ans += 1
print(ans)


n = int(input())
l_list = list(map(int, input().split()))
l_sorted = sorted(l_list, reverse=True)
combination_count = 0
for i in range(n - 2):
	l1 = l_sorted[i]
	for j in range(i + 1, n - 1):
		l2 = l_sorted[j]
		for k in range(j + 1, n):
			l3 = l_sorted[k]
			if len(set([l1, l2, l3])) == 3:
				if l1 < l2 + l3:
					combination_count += 1
				else:
					break
print(combination_count)


(n, *l) = map(int, open(0).read().split())
ans = 0
l.sort()
for i in range(n):
	for j in range(i):
		for k in range(j):
			if l[k] == l[j] or l[j] == l[i]:
				continue
			if l[k] + l[j] > l[i]:
				ans += 1
print(ans)


N = int(input())
L = list(map(int, input().split()))
count = 0
for i in range(N - 2):
	a = L[i]
	for j in range(N - 2 - i):
		b = L[i + j + 1]
		if a == b:
			continue
		for k in range(N - 2 - i - j):
			c = L[i + j + k + 2]
			if a == c or b == c:
				continue
			if a + b > c and b + c > a and (c + a > b):
				count += 1
print(count)


n = int(input())
l = [*map(int, input().split())]
c = 0
for i in l:
	for j in l:
		for k in l:
			if i != j != k != i and j + k > i and (k + i > j) and (i + j > k):
				c += 1
print(c // 6)


N = int(input())
L = list(map(int, input().split()))
count = 0
for i in range(N - 2):
	for j in range(i + 1, N - 1):
		for k in range(j + 1, N):
			temp = set([L[i], L[j], L[k]])
			if len(temp) != 3:
				continue
			ma = max(temp)
			if ma < sum(temp - {ma}):
				count += 1
print(count)


N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
cnt = 0
for i in range(N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			if L[i] == L[j] or L[j] == L[k]:
				continue
			if L[i] + L[j] > L[k]:
				cnt += 1
print(cnt)


from collections import Counter
N = int(input())
L = list(map(int, input().split()))
C = Counter(L)
L = sorted(set(L))
M = len(L)
ans = 0
for i in range(M):
	for j in range(i + 1, M):
		for k in range(j + 1, M):
			(a, b, c) = (L[i], L[j], L[k])
			if a < b + c and b < c + a and (c < a + b):
				ans += C[a] * C[b] * C[c]
print(ans)


import itertools
n = input()
l = list(map(int, input().split()))
ls = sorted(set(l))
ans = 0
for p in itertools.combinations(ls, 3):
	if p[0] + p[1] > p[2]:
		ans += l.count(p[0]) * l.count(p[1]) * l.count(p[2])
print(ans)


a = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(a):
	for s in range(a):
		for t in range(a):
			if p[t] < p[s] < p[i] and p[t] + p[s] > p[i]:
				count += 1
print(count)


n = int(input())
l = sorted(list(map(int, input().split())), reverse=True)
count = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if l[i] < l[j] + l[k] and l[i] != l[j] != l[k]:
				count += 1
print(count)


n = int(input())
ls = list(map(int, input().split()))
count = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			(a, b, c) = (ls[i], ls[j], ls[k])
			if (a + b > c and b + c > a and (c + a > b)) and (a != b and b != c and (c != a)):
				count += 1
print(count)


n = int(input())
l = list(map(int, input().split()))
ans = 0
for a in l:
	for b in l:
		for c in l:
			if (a != b and b != c and (a != c)) and abs(b - c) < a < b + c:
				ans += 1
print(ans // 6)


import itertools
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
C = itertools.combinations(range(n), 3)
for (a, b, c) in C:
	if l[a] + l[b] > l[c] and l[a] != l[b] and (l[b] != l[c]) and (l[a] != l[c]):
		ans += 1
print(ans)


from sys import stdin
N = int(stdin.readline().rstrip())
L = sorted([int(_) for _ in stdin.readline().rstrip().split()])
ans = 0
for i in range(N - 2):
	for j in range(i + 1, N - 1):
		for k in range(j + 1, N):
			if L[i] + L[j] > L[k] > L[j] > L[i]:
				ans += 1
print(ans)


import itertools
n = int(input())
L = list(map(int, input().split()))
L.sort()
answer = 0
for ls in itertools.combinations(L, 3):
	if ls[0] + ls[1] > ls[2] and (ls[0] != ls[1] and ls[1] != ls[2]):
		answer += 1
print(answer)


import itertools

def b175(n, llist):
	ans = 0
	itelist = list(itertools.combinations(range(len(llist)), 3))
	for (a, b, c) in itelist:
		if llist[a] + llist[b] > llist[c] and llist[b] + llist[c] > llist[a] and (llist[c] + llist[a] > llist[b]) and (llist[a] != llist[b]) and (llist[b] != llist[c]) and (llist[c] != llist[a]):
			ans += 1
	return ans

def main():
	n = int(input())
	llist = list(map(int, input().split()))
	print(b175(n, llist))

def __starting_point():
	main()
__starting_point()


n = int(input())
L = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in L:
	for j in L:
		for k in L:
			if i < j < k:
				if i + j > k:
					ans += 1
print(ans)


N = int(input())
L = list(map(int, input().split()))
count = 0
for i in range(N):
	for j in range(N):
		for k in range(N):
			if not i < j < k:
				continue
			if len(set([L[i], L[j], L[k]])) < 3:
				continue
			if L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and (L[j] + L[k] > L[i]):
				count += 1
print(count)


n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		if l[i] == l[j]:
			continue
		for k in range(j + 1, n):
			if l[i] != l[k] != l[j] and max(l[i], l[j], l[k]) < l[i] + l[j] + l[k] - max(l[i], l[j], l[k]):
				ans += 1
print(ans)


(n, *l) = map(int, open(0).read().split())
l.sort()
print(sum((i < j < k and i + j > k for i in l for j in l for k in l)))


from itertools import combinations as comb
N = int(input())
L = list(map(int, input().split()))
count = 0
for (a, b, c) in comb(L, 3):
	if a != b and b != c and (c != a) and (a + b > c) and (b + c > a) and (c + a > b):
		count += 1
print(count)


N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N - 2):
	for j in range(i + 1, N - 1):
		for k in range(j + 1, N):
			(a, b, c) = (L[i], L[j], L[k])
			if a != b and a != c and (b != c) and (a + b > c):
				ans += 1
print(ans)


import itertools
N = int(input().strip())
L = [int(i) for i in input().strip().split(' ')]
cnt = 0
for i in itertools.combinations(L, r=3):
	i = sorted(i)
	if len(set(i)) == 3:
		if sum(i[:2]) > i[2]:
			cnt += 1
print(cnt)


import itertools
n = input()
x = 0
s = list(map(int, input().split()))
s2 = set(s)
s3 = sorted(s2)
s4 = list(itertools.combinations(s3, 3))
for i in s4:
	if i[0] + i[1] > i[2]:
		x = x + s.count(i[0]) * s.count(i[1]) * s.count(i[2])
print(x)


n = int(input())
l = [*map(int, input().split())]
ans = 0
for i in range(n - 2):
	for j in range(i, n - 1):
		for k in range(j, n):
			if abs(l[i] - l[j]) < l[k] < l[i] + l[j] and l[i] != l[j] and (l[j] != l[k]) and (l[k] != l[i]):
				ans += 1
print(ans)


import itertools
N = int(input())
L = list(map(int, input().split()))
ans = 0
for v in itertools.combinations(L, 3):
	l = sorted(v)
	if len(set(l)) == 3:
		if l[2] < l[1] + l[0]:
			ans += 1
print(ans)


from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
c = combinations(l, 3)
ans = 0
for (a, b, c) in c:
	if a + b > c and b + c > a and (c + a > b) and (a != b) and (b != c) and (a != c):
		ans += 1
print(ans)


import math
import copy
import string
INF = int(10 ** 18)
pi = math.pi
MOD = 1000000007

def my_pow(N, a, M):
	if a == 0:
		return 1
	elif a % 2 == 0:
		tempo = my_pow(N, a / 2, M)
		return tempo * tempo % M
	else:
		tempo = my_pow(N, a - 1, M)
		return tempo * N % M

def my_combination(N, a, M):
	res = 1
	for i in range(0, a):
		res *= N - i
		res %= M
	for i in range(0, a):
		res *= my_pow(i + 1, M - 2, M)
		res %= M
	return res

def my_combination_table(N, M, v):
	if len(v) < N + 1:
		l = N + 1 - len(v)
		tempo = [1] * l
		v.extend(tempo)
	for i in range(1, N + 1):
		v[i] = v[i - 1] * (N - (i - 1))
		v[i] %= M
		v[i] *= my_pow(i, M - 2, M)
		v[i] %= M
	return
N = int(input())
L = [int(x) for x in input().split()]
res = 0
for i in range(0, N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			tempo = [L[i], L[j], L[k]]
			tempo.sort()
			if tempo[0] + tempo[1] > tempo[2] and tempo[0] < tempo[1] and (tempo[1] < tempo[2]):
				res += 1
print(res)


def isTri(a, b, c):
	if (a != b and b != c and (c != a)) and (a + b > c and b + c > a and (c + a > b)):
		return True
	else:
		return False

def main():
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				if isTri(l[i], l[j], l[k]):
					c += 1
	print(c)
main()


def is_triangle(x, y, z):
	return x + y > z and x != y and (y != z) and (x != z)
N = int(input())
L = sorted(list(map(int, input().split())))
from itertools import combinations
print(len([(x, y, z) for (x, y, z) in combinations(L, 3) if is_triangle(x, y, z)]))


n = int(input())
l = list(map(int, input().split()))
import itertools
ans = 0
for i in itertools.combinations(l, 3):
	if abs(i[0] - i[1]) < i[2] and i[2] < i[0] + i[1] and (i[0] != i[1]) and (i[1] != i[2]) and (i[2] != i[0]):
		ans += 1
print(ans)


n = int(input())
l = [int(_) for _ in input().split()]
print(sum((i < j < k < i + j for i in l for j in l for k in l)))


import itertools
N = int(input())
L = list(map(int, input().split(' ')))
l = 0
T = []
for u in list(itertools.combinations(L, 3)):
	(i, j, k) = u
	if 2 * max(i, j, k) < i + j + k and i != k and (i != j) and (j != k):
		l = l + 1
print(l)


N = int(input())
L = list(map(int, input().split()))
if N < 3:
	print(0)
	return
L = sorted(L)
res = 0
for k in range(N):
	for j in range(k):
		for i in range(j):
			if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
				continue
			if L[i] + L[j] <= L[k]:
				continue
			res += 1
print(res)


(n, *a) = map(int, open(0).read().split())
print(sum((i < j < k < i + j for k in a for j in a for i in a)))


N = int(input())
L = list(map(int, input().split()))
L_sort = sorted(L)
Y_count = 0
N_count = 0
import itertools
for x in itertools.combinations(L_sort, 3):
	if x[0] != x[1] and x[1] != x[2] and (x[0] != x[2]) and (x[0] + x[1] > +x[2]) and (x[1] + x[2] >= x[0]) and (x[0] + x[2] >= x[1]):
		Y_count = Y_count + 1
	else:
		N_count = N_count + 1
print(Y_count)


def solve(n, l):
	l = sorted(l)
	ans = 0
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				if l[i] < l[j] < l[k] and l[i] + l[j] > l[k]:
					ans += 1
	return ans
n = int(input())
l = list(map(int, input().split()))
print(solve(n, l))


import itertools
n = int(input())
L = list(map(int, input().split()))
L.sort()
c = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if L[i] + L[j] > L[k] and L[i] != L[j] and (L[j] != L[k]):
				c += 1
print(c)


from itertools import combinations
N = int(input())
L = tuple(map(int, input().split()))
cnt = 0
for (a, b, c) in combinations(L, 3):
	if a == b or b == c or c == a:
		continue
	cnt += int(max(a, b, c) * 2 < a + b + c)
print(cnt)


n = int(input())
l = sorted(map(int, input().split()))
ans = 0
for a in range(n):
	for b in range(a + 1, n):
		for c in range(b + 1, n):
			if l[a] != l[b] != l[c] and l[a] + l[b] > l[c]:
				ans += 1
print(ans)


N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
from itertools import combinations
LC = list(combinations(L, 3))
for l in LC:
	if l[2] < l[0] + l[1]:
		s = set(l)
		if len(s) == 3:
			ans += 1
print(ans)


import itertools as it
N = int(input())
ans = 0
K = list(map(int, input().split()))
for i in it.combinations_with_replacement(K, 3):
	a = i[0]
	b = i[1]
	c = i[2]
	if a != b and b != c and (c != a):
		if a + b > c and b + c > a and (c + a > b):
			ans += 1
print(ans)


N = int(input())
L = list(map(int, input().split()))
L.sort()
P = 0
for i in range(N - 2):
	for j in range(i + 1, N - 1):
		for k in range(j + 1, N):
			if L[i] + L[j] > L[k] and len(set([L[i], L[j], L[k]])) == 3:
				P += 1
print(P)


def main():
	n = int(input())
	s = input()
	l = s.split()
	l = [int(x) for x in l]
	l.sort()
	cnt = 0
	for i in range(n):
		for j in range(i + 1, n):
			if l[i] == l[j]:
				continue
			for k in range(j + 1, n):
				if l[i] == l[k] or l[j] == l[k]:
					continue
				cnt += triangle(l[i], l[j], l[k])
	print(cnt)

def triangle(a, b, c):
	if a + b > c and b + c > a and (c + a > b):
		return 1
	else:
		return 0

def __starting_point():
	main()
__starting_point()


import itertools
N = int(input())
L = list(map(int, input().split()))
count = 0
pair_list = []
for pair in itertools.combinations(L, 3):
	a = sorted(list(pair))
	if (a[0] != a[1] and a[0] != a[2] and (a[1] != a[2])) and abs(a[0] - a[1]) < a[2] and (a[2] < a[0] + a[1]):
		count = count + 1
		pair_list.append(a)
print(count)


import sys

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

def ri():
	return int(rs())

def rs_():
	return [_ for _ in rs().split()]

def ri_():
	return [int(_) for _ in rs().split()]
N = ri()
L = ri_()

def f(L):
	L_ = sorted(L)
	return len(set(L_)) == 3 and L_[0] + L_[1] > L_[2]
ans = 0
for i in range(N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			if f([L[i], L[j], L[k]]):
				ans += 1
print(ans)


from itertools import combinations
N = int(input())
L = list(map(int, input().split()))
ans = 0
for (x, y, z) in combinations(L, 3):
	(x, y, z) = sorted((x, y, z))
	if x < y < z and x + y > z:
		ans += 1
print(ans)


import itertools
N = int(input())
L = list(map(int, input().split()))
count = 0
for list in itertools.combinations(L, 3):
	if len(set(list)) == 3 and max(list) < sum(list) - max(list):
		count += 1
print(count)


import itertools
N = int(input())
L = [int(_) for _ in input().split()]
ans = 0
for (i, j, k) in itertools.combinations(range(N), 3):
	(a, b, c) = sorted([L[i], L[j], L[k]])
	if a + b > c and a != b and (b != c):
		ans += 1
print(ans)


import itertools
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for v in itertools.combinations(l, 3):
	t = set(v)
	if len(t) == len(v) and abs(v[0] - v[1]) < v[2] < v[0] + v[1]:
		cnt += 1
print(cnt)


N = int(input())
A = list(map(int, input().split()))
A.sort()
cnt = 0
for i in range(0, N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			if A[i] != A[j] != A[k]:
				if A[i] + A[j] > A[k]:
					cnt += 1
print(cnt)


import itertools
n = int(input())
l = list(map(int, input().split()))
p_list = list(itertools.permutations(l, 3))
results = [x for x in p_list if max(x) < sum(x) - max(x) and len(x) == len(set(x))]
print(int(len(results) / 6))


N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			if len(set([L[i], L[j], L[k]])) == 3 and L[i] + L[j] > L[k]:
				ans += 1
print(ans)


import itertools
N = int(input())
L = [int(i) for i in input().split()]
cnt = 0
L.sort()
for v in itertools.combinations(L, 3):
	if v[2] < v[0] + v[1] and len(set(v)) == 3:
		cnt += 1
print(cnt)


import itertools
N = int(input())
l = map(int, input().split())
cnt = 0
for (a, b, c) in itertools.combinations(l, 3):
	if abs(a - b) < c < a + b and len(set([a, b, c])) == 3:
		cnt += 1
print(cnt)


n = int(input())
hen_list = list(map(int, input().split()))
count = 0
for x in hen_list:
	for y in hen_list:
		for z in hen_list:
			if (z > x and z > y and (y > x)) and x + y > z:
				count += 1
print(count)


n = int(input())
L = sorted(map(int, input().split()))
x = 0
for i in L:
	for j in L[:i]:
		if j == i:
			break
		for k in L[:j]:
			if k == j:
				break
			if i < j + k:
				x += 1
print(x)


import itertools
N = int(input())
L = sorted(list(map(int, input().split())))
SS = itertools.combinations(L, 3)
count = 0
for (x, y, z) in SS:
	if x + y > z and x + z > y and (y + z > x) and (x != y != z):
		count += 1
print(count)


n = int(input())
l = sorted(map(int, input().split()))
n = len(l)
ans = 0
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if l[i] + l[j] > l[k] > l[j] > l[i]:
				ans += 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(0, n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			x = [l[i], l[j], l[k]]
			ma = sorted(x)[2]
			_ma = sorted(x)[0] + sorted(x)[1]
			if l[i] != l[j] and l[i] != l[k] and (l[j] != l[k]) and (ma < _ma):
				cnt += 1
print(cnt)


N = int(input())
hen = []
hen = list((int(x) for x in input().split()))
hen.sort()
tri = 0
for a in hen:
	for b in hen:
		if a == b or a > b:
			continue
		for c in hen:
			if a == c or b == c or a > c or (b > c):
				continue
			if a + b > c and b + c > a and (c + a > b):
				tri += 1
print(tri)


N = int(input())
L = list(map(int, input().split()))
import itertools
comb = itertools.combinations(L, 3)
ans = 0
for c in comb:
	if len(set(c)) != 3:
		continue
	tmp = sorted(c)
	if tmp[2] < tmp[1] + tmp[0]:
		ans += 1
print(ans)


def main():
	N = int(input())
	L = [int(l) for l in input().split(' ')]
	cnt = 0
	L.sort()
	for i in range(len(L)):
		for j in range(i + 1, len(L)):
			for k in range(j + 1, len(L)):
				if L[k] < L[i] + L[j] and L[i] != L[j] and (L[j] != L[k]):
					cnt += 1
	print(cnt)
main()


from itertools import combinations
n = int(input())
l = map(int, input().split())
count = 0
for i in combinations(l, 3):
	c = sorted(set(i))
	if len(c) == 3:
		if c[0] + c[1] > c[2]:
			count += 1
print(count)


import itertools as it
n = int(input())
a = sorted(map(int, input().split()))
print(sum((sum(x) > 2 * x[2] and len(x) == len(set(x)) for x in it.combinations(a, 3))))


def main():
	N = int(input())
	L = list(map(int, input().split()))
	if N < 3:
		print(0)
		return
	ans = 0
	for i in range(N - 2):
		for j in range(i + 1, N - 1):
			for k in range(j + 1, N):
				Li = L[i]
				Lj = L[j]
				Lk = L[k]
				if Li != Lj and Lj != Lk and (Lk != Li) and (Li < Lj + Lk) and (Lj < Li + Lk) and (Lk < Li + Lj):
					ans += 1
	print(ans)
	return

def __starting_point():
	main()
__starting_point()


N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for l1 in L:
	for l2 in L:
		for l3 in L:
			ans += l1 != l2 and l2 != l3 and (l3 != l1) and (2 * max(l1, l2, l3) < l1 + l2 + l3)
print(ans // 6)


from itertools import combinations
from typing import List

def answer(n: int, l: List[int]) -> int:
	count = 0
	l.sort()
	for (i, j, k) in combinations(l, 3):
		if i != j != k and k < i + j:
			count += 1
	return count

def main():
	n = int(input())
	l = list(map(int, input().split()))
	print(answer(n, l))

def __starting_point():
	main()
__starting_point()


import itertools
N = int(input())
L = list(map(int, input().split()))
l = list(itertools.combinations(set(L), 3))
count = 0
for (a, b, c) in l:
	if a + b > c and b + c > a and (c + a > b):
		count += 1 * L.count(a) * L.count(b) * L.count(c)
print(count)


(N,) = map(int, input().split())
A = list(map(int, input().split()))
c = 0
n = len(A)
if len(A) < 3:
	print(0)
	return
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if 2 * max(A[i], A[j], A[k]) - sum([A[i], A[j], A[k]]) >= 0 or A[i] == A[j] or A[j] == A[k] or (A[k] == A[i]):
				continue
			c += 1
print(c)


n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(0, n):
	for j in range(i + 1, n):
		if l[i] == l[j]:
			continue
		for k in range(j + 1, n):
			if l[j] == l[k]:
				continue
			if l[i] + l[j] > l[k]:
				ans += 1
print(ans)


from itertools import combinations
N = int(input())
L = [int(i) for i in input().split()]
ans = 0
for (a, b, c) in combinations(L, 3):
	if a != b and b != c and (c != a) and (a + b > c) and (b + c > a) and (c + a > b):
		ans += 1
print(ans)


N = int(input())
L = list(map(int, input().split()))
import itertools as it
c = it.combinations(L, 3)
count = 0
for i in c:
	if len(set(i)) == 3:
		(a, b, c) = sorted(i, reverse=True)
		if a < b + c:
			count += 1
print(count)


n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
	for j in range(i):
		for k in range(j):
			ans += abs(l[i] - l[j]) < l[k] < abs(l[i] + l[j]) and len({l[i], l[j], l[k]}) == 3
print(ans)


n = int(input())
l = list(map(int, input().split()))
cnt = 0
import itertools
for (a, b, c) in itertools.combinations(l, 3):
	if a == b or a == c or b == c:
		cnt += 0
	elif a + b <= c or a + c <= b or b + c <= a:
		cnt += 0
	else:
		cnt += 1
print(cnt)


from itertools import *
(_, L) = open(0)
print(sum((sum(t) > 2 * max(t) for t in combinations(map(int, L.split()), 3) if len(set(t)) == 3)))


from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
res = 0
for (i, j, k) in combinations(l, 3):
	if i != j != k != i:
		if i < j + k and j < i + k and (k < i + j):
			res += 1
print(res)


N = int(input())
nums = [int(i) for i in input().split()]
nums = sorted(nums)
ans = 0
for i in range(N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			if nums[i] != nums[j] and nums[j] != nums[k]:
				if nums[i] + nums[j] > nums[k]:
					ans += 1
print(ans)


import itertools
N = int(input())
L = list(map(int, input().split()))
cnt = 0
for (i, j, k) in itertools.combinations(L, 3):
	if abs(j - k) < i and i < j + k:
		if i != j and j != k and (k != i):
			cnt += 1
print(cnt)


from itertools import *
N = int(input())
L = list(map(int, input().split()))
ans = 0
for C in combinations(L, 3):
	C = sorted(C)
	if len(set(C)) == 3 and C[2] < C[0] + C[1]:
		ans += 1
print(ans)


def input_int():
	return int(input())

def int1(x):
	return int(x) - 1

def input_to_int_map():
	return list(map(int, input().split()))

def input_to_int_tuple():
	return tuple(map(int, input().split()))

def input_to_int_tuple_minus1():
	return tuple(map(int1, input().split()))

def main():
	N = input_int()
	L = input_to_int_tuple()
	distinct_L = set(L)
	ret = 0
	if len(distinct_L) < 3:
		return ret
	for i in range(N):
		for j in range(i + 1, N):
			for k in range(j + 1, N):
				(li, lj, lk) = (L[i], L[j], L[k])
				sorted_val = sorted([li, lj, lk])
				if sorted_val[0] != sorted_val[1] != sorted_val[2] and sorted_val[0] + sorted_val[1] > sorted_val[2]:
					ret += 1
	return ret

def __starting_point():
	print(main())
__starting_point()


n = int(input())
s = input().split()
s = [int(i) for i in s]
s.sort()
a = 0
for i in range(len(s) - 2):
	for j in range(i + 1, len(s) - 1):
		for k in range(j + 1, len(s)):
			if s[i] != s[j] and s[j] != s[k] and (s[i] + s[j] > s[k]):
				a += 1
print(a)


import itertools
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in itertools.combinations(l, 3):
	(x, y, z) = (i[0], i[1], i[2])
	if x != y and y != z and (z != x) and (x + y > z) and (y + z > x) and (x + z > y):
		ans += 1
print(ans)


N = int(input())
li = list(map(int, input().split()))
from itertools import combinations
ans = 0
for k in combinations(li, 3):
	k = list(k)
	k.sort()
	if k[0] + k[1] > k[2] and k[0] != k[1] and (k[1] != k[2]):
		ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			b = sorted(set(list([a[i], a[j], a[k]])))
			if len(b) == 3 and b[0] + b[1] > b[2]:
				ans += 1
print(ans)


from itertools import *
(n, *a) = map(int, open(0).read().split())
a.sort()
ans = 0
for (i, j, k) in combinations(a, 3):
	if i < j < k and i + j > k:
		ans += 1
print(ans)


import itertools
n = int(input())
l = list(map(int, input().split()))
num = 0
for (i, h, j) in itertools.combinations(l, 3):
	if i + h > j and h + j > i and (j + i > h) and (j != i) and (i != h) and (h != j):
		num += 1
print(num)


N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(len(L) - 2):
	for j in range(i + 1, len(L) - 1):
		for k in range(j + 1, len(L)):
			if L[k] < L[j] + L[i]:
				if L[k] != L[j] and L[j] != L[i]:
					cnt += 1
print(cnt)


N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(N):
	for j in range(i + 1, N):
		for k in range(j + 1, N):
			a = L[i]
			b = L[j]
			c = L[k]
			if abs(b - c) < a < b + c and a != b and (b != c):
				cnt += 1
print(cnt)


import itertools
N = int(input())
l = list(map(int, input().split()))
ctn = 0
for c in itertools.combinations(l, 3):
	if len(c) == len(set(c)):
		if sorted(c)[0] + sorted(c)[1] - sorted(c)[2] > 0:
			ctn += 1
print(ctn)


n = int(input())
lll = list(map(int, input().split()))
lll.sort()
len_lll = len(lll)
ans = 0
for i in range(len_lll):
	a = lll[i]
	for j in range(i + 1, len_lll):
		b = lll[j]
		for k in range(j + 1, len_lll):
			c = lll[k]
			if a + b > c and a != b and (b != c):
				ans += 1
print(ans)


n = int(input())
array = sorted(map(int, input().split()))
count = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if array[i] < array[j] and array[j] < array[k] and (array[i] + array[j] > array[k]):
				count += 1
print(count)