Problem:
 Score : 200 points    Problem Statement 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 1 5
4 4 9 7 5      Sample Output 1 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) .       Sample Input 2 6
4 5 4 3 3 5      Sample Output 2 8  We have two sticks for each of the lengths 3 , 4 , and 5 . To satisfy the first condition, we have to choose one from each length.  There is a triangle whose sides have lengths 3 , 4 , and 5 , so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.       Sample Input 3 10
9 4 6 1 9 6 10 6 6 8      Sample Output 3 39       Sample Input 4 2
1 1      Sample Output 4 0  No triple (i, j, k) satisfies 1 \leq i < j < k \leq N , so we should print 0 .

Solution (Python):
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    
    t=1
    for _ in range(t):

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

        print(ans)




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

Solution (Python):





def p(X):
    print(X)
N = int(input())
S = list(map(int, input().split()))
count = 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)):
            result = [S[i],S[j],S[k]]
            re = sorted(result,reverse=True)
            if (S[i] != S[j] and S[i] != S[k] and S[j] !=S[k]) and (re[0]< re[1]+re[2]):
                count +=1

p(count)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))

res = 0
for i in range(N):
    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[k]:
                if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                    res += 1

print(res)

Solution (Python):
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)

Solution (Python):
import itertools

n = int(input())
L = list(map(int, input().split()))
cnt = 0
for i, j, k in itertools.combinations(list(range(n)), 3):
    if (L[i] != L[j]) and (L[j] != L[k])and (L[i] != L[k]):
        if (L[i] < L[j] + L[k]) and (L[j] < L[i] + L[k]) and (L[k] < L[i] + L[j]):
            cnt += 1
print(cnt)

Solution (Python):
N=int(input())
L=list(map(int, input().split()))

ct=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[j]<L[k]+L[i] and L[k]<L[i]+L[j] and \
               L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                ct+=1
                

print(ct)

Solution (Python):
n = int(input())
L=list(map(int,input().split()))
import itertools
p = list(itertools.combinations(L, 3))

cnt=0
for j in range(len(p)):
    m =p[j].index(max(p[j]))
    if len(list(set(p[j]))) ==3:
        if m==0:
            if abs(p[j][1]-p[j][2]) < p[j][m] < p[j][1]+p[j][2]:
                cnt+=1
        elif m==1:
            if abs(p[j][0]-p[j][2]) < p[j][m] < p[j][0]+p[j][2]:
                cnt+=1 
        elif m==2:
            if abs(p[j][0]-p[j][1]) < p[j][m] < p[j][0]+p[j][1]:
                cnt+=1
print(cnt)

Solution (Python):
import itertools as it

N = int(input())
sides = [int(i) for i in input().split()]


combs = it.combinations(sides, 3)
combs = it.filterfalse(lambda x: not (x[0] != x[1] and x[1] != x[2] and x[0] != x[2]) ,combs)



def is_triangle(comb):
    if comb[0] + comb[1] > comb[2] and comb[1] + comb[2] > comb[0] and comb[0] + comb[2] > comb[1]:
        return True
    return False

count = 0
for comb in combs:
    if is_triangle(comb):
        count += 1

print(count)

Solution (Python):
N = int(input())
L = list(map(int,input().split()))
L.sort()
a = 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] and L[j] < L[k] and L[i] + L[j] > L[k]:
        a += 1
print(a)

Solution (Python):
a = int(input())
ar = list(map(int,input().split(" ")))
if a < 3:
    print(0)
    exit()
count = 0
for i in range(a-2):
    for j in range(i+1,a-1):
        for k in range(j+1,a):
            if ar[i] != ar[j] and ar[j] != ar[k] and ar[i] != ar[k]:
                br = [ar[i],ar[j],ar[k]]
                br.sort()
                if br[0] + br[1] > br[2]:
                    count += 1
print(count)

Solution (Python):
N = int(input())
line = (input())

strL = line.split()

lenL = len(strL)
ans = 0


L = list(map(int, strL))

if lenL < 3:
    ans = 0
else:
    L.sort()
    for i in range(0, lenL-2):
        for j in range(i+1, lenL-1):
            if L[i] == L[j] :
                continue
            for k in range(j+1, lenL):
                
                if L[j] == L[k] or L[k] == L[i]:
                    
                    continue
                if L[i] + L[j] <= L[k]:
                    
                    break
                else:
                    
                    ans += 1
print(ans)

Solution (Python):
def main():
    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):
                l = [L[i], L[j], L[k]]
                l.sort()
                if l[0] == l[1] or l[1] == l[2] :
                    continue
                if l[0]+l[1] > l[2] :
                    count+=1
    print(count)

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
l = 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 l[i] == l[j] or l[k] == l[j] or l[i] == l[k]:
                continue
            elif l[i] + l[j] > l[k] and l[k] + l[j] > l[i] and l[i] + l[k] > l[j]:
                ans += 1
print(ans)

Solution (Python):
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[i] < L[j] < L[k]:
                ans += 1
print(ans)

Solution (Python):
N=int(input())
L=list(map(int,input().split()))


if N<=2:
    print(0)
    exit()

ans =0

for i in range(0,N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (L[i]-L[j])*(L[j]-L[k])*(L[i]-L[k]) != 0 and L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
                ans += 1

print(ans)

Solution (Python):
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]:
                if l[i] + l[j] > l[k]:
                    ans += 1
print(ans)

Solution (Python):
n = int(input())
l = list(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):
      if l[i] != l[j] and l[j] != l[k] and l[i] + l[j] > l[k]:
        ans += 1
print(ans)

Solution (Python):
N, *L = map(int,open(0).read().split())
def check_different_length(a,b,c):
    if a == b or a == c or b == c:
        return False
    else:
        return True

def check_can_make(a,b,c):
    if a >= b+c or b >= a+c or c >= a+b:
        return False
    else:
        return True

cnt = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        for c in range(b+1,N):
            if check_different_length(L[a],L[b],L[c]):
                if check_can_make(L[a],L[b],L[c]):
                    cnt += 1
print(cnt)

Solution (Python):
import sys

n=int(input())
l=[int(x) for x in input().rstrip().split()]
l.sort()


ans=0
for i in range(n):
  for j in range(i+1,n):
    for s in range(j+1,n):
      if l[i]!=l[j] and l[j]!=l[s] and l[i]!=l[s]:
        if l[i]<l[j]+l[s] and l[j]<l[i]+l[s] and l[s]<l[i]+l[j]:
          ans+=1
print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
a.sort()
res = 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] != a[k]:
                if a[i] + a[j] > a[k]:
                    res += 1
print(res)

Solution (Python):
def conbination(dct):
    for i in range(len(dct)-2):
        for j in range(i+1,len(dct)-1):
            for k in range(j+1,len(dct)):
                v_lst = list(dct.values())
                k_lst = list(dct.keys())
                l = [ int(k_lst[i]), int(k_lst[j]), int(k_lst[k]) ]
                l_sorted = sorted(l)
                if l_sorted[2] < l_sorted[0] + l_sorted[1]:
                    global cnt 
                    cnt += v_lst[i]*v_lst[j]*v_lst[k]
    return cnt

N = int(input())
L = input().split()
D = dict()
cnt = 0
for i in range(len(L)):
    if L[i] in D.keys():
        D[L[i]] += 1
    elif not L[i] in D.keys():
        D[L[i]] = 1
if len(D) < 3:
    print(0)
elif len(D) >= 3:
    print(conbination(D))

Solution (Python):
N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0

for i in range(N) :
  li = L[i]
  for j in range(i+1, N) :
    flag = False
    lj = L[j]
    if li == lj :
      continue
    for k in range(j+1, N) :
      lk = L[k]
      if lj == lk :
        continue
      if flag :
        continue
      if li + lj > lk :
        ans += 1
      else :
        flag = True
        
print(ans)

Solution (Python):
n = int(input())
l = sorted(list(map(int, input().split())))
cnt = 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:
                continue
            if l[k] < l[i] + l[j]:
                cnt += 1
print(cnt)

Solution (Python):
def max(x):
    p = x[0]
    for i in range(0,len(x)):
        if p < x[i]:
            p = x[i]
        else:
            p = p
    return p
        
n = int(input())
s = list(map(int, input().split()))
q = 0
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] or s[i] == s[k] or s[j] == s[k]:
                q = q
            else:
                if s[i] + s[j] + s[k] - max([s[i],s[j],s[k]]) > max([s[i],s[j],s[k]]):
                    q = q + 1
                else:
                    q = q
print(q)

Solution (Python):
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):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue
            max_l = max(l[i],l[j],l[k])
            if 2*max_l < l[i]+l[j]+l[k]:
                count +=1
print(count)

Solution (Python):
read = lambda:list(map(int, input().split()))
n = int(input())
l = read()
l.sort()
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[j] == l[k]:
                continue
            if l[i] + l[j] > l[k]:
                ans += 1
print(ans)

Solution (Python):
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):
            if len(set([l[i], l[j], l[k]])) == 3 and max(l[i], l[j], l[k]) < sum([l[i], l[j], l[k]]) - max(l[i], l[j], l[k]):
                ans += 1
print(ans)

Solution (Python):
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))

Solution (Python):
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] or l[j] == l[k]:
                continue
            if l[i] + l[j] > l[k]:
                ans += 1

print(ans)

Solution (Python):
n=int(input())
a=input().split()
count=0

for t in range(n):
  a[t]=int(a[t])
  
for i in range(n-2):
  for j in range(n-2):
    if j>=i:
      for k in range(n-2):
        if k>=j:
          if a[i]!=a[j+1] and a[j+1]!=a[k+2] and a[k+2]!=a[i]:
            if a[i]+a[j+1]>a[k+2] and a[j+1]+a[k+2]>a[i] and a[k+2]+a[i]>a[j+1]:
              count+=1
print(count)

Solution (Python):
from itertools import combinations
n = int(input())
L = sorted(map(int, input().split()))
ans = 0
for subset in combinations(L, 3):
    a, b, c = subset
    if len(set(subset)) != 3:
        continue
    if c < a+b:
        ans += 1
print(ans)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
ans=0

for i in L:
    for j in L:
        for k in L:
            if (not i==j and not j==k and not i==k):
                if ( i+j>k and  i+k>j and k+j>i):
                    ans+=1

ans=ans/6
print(int (ans))

Solution (Python):
import itertools
n=int(input())
l=list(map(int,input().split()))
c_list=list(itertools.combinations(l,3))
ans=0
for i in c_list:
    if(i[0]+i[1]>i[2] and i[1]+i[2]>i[0] 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)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))

L.sort()
count = 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] > L[k] and L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                count += 1

print(count)

Solution (Python):
n = int(input())
L = 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):
            a, b, c = sorted([L[i], L[j], L[k]])
            if a == b or b == c or c == a:
                continue
            if c < a+b:
                ans += 1
print(ans)

Solution (Python):
N=int(input())
L=list(map(int,input().split()))
list.sort(L,reverse=True)
count=0
if N>2:
    for x in range(N):
        for y in range(x+1,N):
            for z in range(y+1,N):
                if L[x]==L[y]:
                    break
                elif (L[z]!=L[y])and(L[x]<(L[y]+L[z])):
                    count+=1
print(count)

Solution (Python):
n=input()
L=[int(x) for x in input().split()]

t=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] or L[j]==L[k] or L[k]==L[i]:
        continue
      if L[i]<L[j]+L[k] and L[j]<L[i]+L[k] and L[k]<L[i]+L[j]:
        t+=1

print(t)

Solution (Python):
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



N = I()
L = LI()

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[k] > L[j] and L[j]+L[k] > L[i]:
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    count += 1

print(count)

Solution (Python):
def resolve():
    N = int(input())
    if N < 3:
        print(0)
        return
    L = list(sorted([int(i) for i in 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[j] == L[k]:
                    continue
                if L[i] + L[j] <= L[k]:
                    break
                ans += 1
    print(ans)

resolve()

Solution (Python):
N = int(input())
L = list(map(int,input().split()))
L.sort()

def checkTri(a,b,c):
  if a == b or b == c or a == c:
    return False
  if abs(a-c) < b < a+c:
    return True
  else:
    return False

cnt = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      if checkTri(L[i],L[j],L[k]):
        cnt += 1
      
print(cnt)

Solution (Python):
n = int(input())
L = 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 L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and 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)

Solution (Python):
from collections import Counter
from bisect import bisect_left
import sys
input = sys.stdin.readline


def main():
    _ = int(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()

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            tri = [l[i], l[j], l[k]]
            if len(set(tri)) != 3:
                continue
            if 2*max(tri) < sum(tri):
                cnt += 1
print(cnt)

Solution (Python):
import sys
read = sys.stdin.readline
import time
from heapq import heappush, heappop
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()


n = inp()
l = inpl()

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[i] < l[j] < l[k] and l[i] + l[j] > l[k]:
                ans += 1
print(ans)



end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

Solution (Python):
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] or L[j] == L[k]: continue

            if L[k] < L[i] + L[j]:
                ans += 1

print(ans)

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

Solution (Python):
n = int(input())
l = 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 l[i] !=  l[j] != l[k]:
                if l[i] + l[j] > l[k]:
                    count+=1
print(count)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(N):
        for k in range(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]:
                ans += 1
print(ans // 6)

Solution (Python):
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):
            if l[i] != l[j] != l[k]:
                if l[i] + l[j] > l[k]:
                    cnt += 1

print(cnt)

Solution (Python):
def solve():
    N = int(input())
    L = sorted(map(int, input().split()))
    N = len(L)
    if N < 3:
        print(0)
        return
    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            a = L[i]
            b = L[j]
            if a == b:
                continue
            for k in range(j+1, N):
                c = L[k]
                if a == c or b == c:
                    continue
                if a + b <= c:
                    break
                ans += 1
    print(ans)

solve()

Solution (Python):
N = int(input())
ls = 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):
      if ls[i] + ls[j] > ls[k]:
        if ls[i] != ls[j] and ls[j] != ls[k]:
          ans += 1
      else:
        break
        
print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]










n = I()
l = LI()
c = itertools.combinations(l, 3)
ans = 0
def check(i,j,k):
    if abs(i-j) < k < i+j and abs(i-k) < j < i+k and abs(k-j) < i < k+j:
        return True
    else:
        return False
for k in c:
    if check(k[0],k[1],k[2]):
        if k[0] != k[1] and k[1] != k[2] and k[2] !=  k[0]:
            ans += 1
print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement, groupby
from math import sqrt, ceil, floor, factorial, gcd
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  
import sys  

n = int(input())
L = list(int(x) for x in input().split())
if n <= 2:
    print(0)
    exit()
ans = 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:
            ans += 1
print(ans)

Solution (Python):
N = int(input())

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

Solution (Python):
import sys
import numpy as np

def main():
    N = int(sys.stdin.readline().rstrip())
    L = [int(x) for x in sys.stdin.readline().rstrip().split()]
    L = np.array(L)
    
    
    cnt = 0

    if N < 3:
        print(0)
        return

    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] or L[j] == L[k] or L[k] == L[i]:
                    continue
                cnt += 1 if L[i] + L[j] > L[k] and L[k] + L[i] > L[j] and L[j] + L[k] > L[i]else 0

    print(cnt)


main()

Solution (Python):
from itertools import combinations

N, *L = map(int, open(0).read().split())

result = 0
for a, b, c in 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:
        result += 1
print(result)

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left
from itertools import product
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def LF(): return list(map(float, input().split()))
def LC(): return [c for c in input().split()]
def LLI(n): return [LI() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]

def array2d(N, M, initial=0):
    return [[initial]*M for _ in range(N)]

def copy2d(orig, N, M):
    ret = array2d(N, M)
    for i in range(N):
        for j in range(M):
            ret[i][j] = orig[i][j]
    return ret


INF = float("inf")
MOD = 10**9 + 7


def main():
    N = INT()
    L = LI()
    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] or L[j] == L[k]:
                    continue
                if L[i]+L[j] > L[k]:
                    count += 1
    print(count)

    return


if __name__ == '__main__':
    main()

Solution (Python):
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] and l[j] != l[k] and l[i]+l[j] > l[k]:
        ans+=1
print(ans)

Solution (Python):
n=int(input())
l = list(map(int, input().split()))

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 a == b or b == c or c == a:
                continue
            else:
                if a<b+c and b<c+a and c<a+b:
                    cnt+=1
print(cnt)

Solution (Python):
N = int(input())
L = [int(l) for l in input().split()]
cnt = 0
for i in range(N):
    Li = L[i]
    for j in range(i + 1, N):
        Lj = L[j]
        for k in range(j + 1, N):
            Lk = L[k]

            if Li != Lj and Lj != Lk and Lk != Li:
                _L = sorted([Li, Lj, Lk])
                if _L[0] + _L[1] > _L[2]:
                    cnt += 1

print(cnt)

Solution (Python):
from sys import stdin
input = stdin.readline

a = input()
nums = list(map(int, input().split()))

res = 0
for i in range(len(nums)-2):
  for j in range(i+1,len(nums)-1):
    if(nums[i]==nums[j]):
      continue
    for k in range(j+1,len(nums)):
      if(nums[i]==nums[k] or nums[j]==nums[k]):
        continue
      
      m = max(nums[i],nums[j],nums[k])
      if m==nums[i] and m<nums[j]+nums[k]:
        res+=1
      elif m==nums[j] and m<nums[i]+nums[k]:
        res+=1
      elif m==nums[k] and m<nums[i]+nums[j]:
        res+=1

print(res)

Solution (Python):
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] or L[j] == L[k] or L[k] == L[i]:
                continue
            if L[i] + L[j] > L[k]:
                count += 1

print(count)

Solution (Python):
import sys
import numpy as np
import math
import collections
import copy
import decimal
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations


N = int(input())
Ln = list(map(int, input().split()))
Ln.sort()
Lc = collections.Counter(Ln)
ans = 0
Cmb = combinations(Lc, 3)
for Cm in Cmb:
    l1, l2, l3 = Cm
    if (l1 + l2 <= l3):
        continue
    ans += Lc[l1] * Lc[l2] * Lc[l3]
print(ans)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))

ans = 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
            a = l[i]
            b = l[j]
            c = l[k]
            if a+b > c and b+c > a and c+a > b:
                ans += 1

print(ans)

Solution (Python):
import itertools

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

if N <= 2:
    print(0)
else:
    L = itertools.combinations(L, 3)
    cnt = 0
    for L1, L2, L3 in L:
        if L1 == L2 or L2 == L3 or L3 == L1:
            continue

        if L3 < L2+L1 and L2 < L1+L3 and L1 < L2+L3:
            cnt += 1
    print(cnt)

Solution (Python):
from collections import Counter
from itertools import combinations


n = int(input())
l = list(map(int, input().split()))

ans = 0
c = Counter(l)

for pat in combinations(c.keys(), 3):
    x, y, z = sorted(pat)
    if x + y > z:
        ans += c[x] * c[y] * c[z]

print(ans)

Solution (Python):
N = int(input())
L = list(map(int,input().split()))


L.sort()

cnt = 0
for i in range(N):
    a = L[i]
    for j in range(i+1,N):
        b = L[j]
        if b == a :
            continue
        for k in range(j+1,N):
            c = L[k]
            if  c == b :
                continue
            elif a + b <= c :
                break
            else:
                
                cnt += 1
print(cnt)