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):
from __future__ import division, print_function






from sys import stdin, stdout
import bisect            
import math
import heapq
i_m=9223372036854775807
def inin():
    return int(input())
def stin():
    return input()
def spin():
    return map(int,stin().split())
def lin():                           
    return list(map(int,stin().split()))
def matrix(n):
    
    return [list(map(int,input().split()))for i in range(n)]


def calculate_sum(a, N): 
    
    m = N / a 
    
    sum = m * (m + 1) / 2
    
    ans = a * sum
    return ans
def series(N):
    return (N*(N+1))//2

def count2Dmatrix(i,list):
    return sum(c.count(i) for c in list)

def modinv(n,p):
    return pow(n,p-2,p)

def GCD(x, y): 
    x=abs(x)
    y=abs(y)
    if(min(x,y)==0):
        return max(x,y)
    while(y): 
        x, y = y, x % y 
    return x
def LCM (x, y):
    return (x * y) // GCD(x, y)
    
def Divisors(n) : 
    l = []  
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                l.append(i) 
            else : 
                l.append(i)
                l.append(n//i)
    return l
def isprime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
prime=[]
def SieveOfEratosthenes(n): 
    global prime
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]: 
            f.append(p)
    return f
q=[]       
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            
    return j

 
"""*******************************************************"""
n = inin()
a = lin()

a = sorted((a))

if len(a)<3:
    print(0)
    exit()

trio = []; c = 0

for i in range(0, len(a)):
    for j in range(0, len(a)):
        for k in range(0, len(a)):
            
            
            if a[i]<a[j]<a[k]:
                if a[i]+a[j]>a[k]:
                    
                    c += 1

print(c)

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[j] == l[k] or l[k] == l[i]:
                continue

            else:
                
                if 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())
s = list(map(int,input().split()))
s.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1, n):
            if s[i] != s[j] != s[k]:
                if s[i]+s[j]>s[k]:
                    ans+=1
print(ans)

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

Solution (Python):
import itertools

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

list = list(itertools.combinations(l,3))

count = 0

for i in list:
    sor = sorted(i)
    a = sor[0]
    b = sor[1]
    c = sor[2]
    if a != b and a != c and b != c and c < (a+b):
      count += 1

print(count)

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

n = len(ns)
tri = []
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if j == k or i == j or i == k or i == j == k:
                pass
            else:
                ts = [ns[i], ns[j], ns[k]]
                m = max(ts)
                rest = sum(ts) - m
                if m < rest:
                    tri.append(ts)
r = []
for i in range(len(tri)):
    t = list(set(tri[i]))
    if len(t) == 3:
        r.append(t)
    
print(len(r))

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

ans = 0
D = {}

for i in L:
    if i in D.keys():
        D[i] += 1
    else:
        D[i] = 1




def judge_triangle(x,y,z):
    m = max(x,y,z)
    if m < x + y + z - m:
        return True
    else:
        return False

K = list(D.keys())

if len(K) <= 2:
    print(0)
    exit(0)

for i in range(len(K)-2):
    for j in range(i+1,len(K)-1):
        for k in range(j+1,len(K)):
            if(judge_triangle(K[i],K[j],K[k])):
                ans += D[K[i]] * D[K[j]] * D[K[k]]

print(ans)

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

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

if N>=3:
    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]!=a[i]:
                    if a[k]<a[i]+a[j]:
                            count+=1
                        
print(count)

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

L2 = list(set(L)) 

ans = 0

for i in range(len(L2)):
  for j in range(i+1, len(L2)):
    for k in range(j+1, len(L2)):
      l = [L2[i], L2[j], L2[k]]
      l = sorted(l, reverse = True)
      if l[0] < l[1] + l[2]:
        ans += L.count(L2[i]) * L.count(L2[j]) * L.count(L2[k])

print(ans)

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

a = 0
for i in itertools.permutations(l,3):
    if i[0] < i[1] and i[1] < i[2] and i[0] + i[1] > i[2] and i[0] + i[2] > i[0] and i[1] + i[2] > i[0]:
        a += 1

print(a)

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

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

tri_list = []

ans = 0
for i in range(0,len(L)):
  for j in range(i,len(L)):
    for k in range(j,len(L)):
      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()))
ans = 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 and b != c and a != c:
        ans+=max(a,b,c)<(b+c+a-max(a,b,c))
print(ans)

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] & l[j] < l[k]:
        if l[i] != l[j] != l[k]:
          if l[i] + l[j] + l[k] > max(l[i],l[j],l[k])*2:
            ans += 1

print(ans)

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

ansL = []

if N <= 2:
    print(0)
else:
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(1+j,N):
                if LS[i] + LS[j] > LS[k] and not LS[i] == LS[j] and not LS[j] == LS[k] and not LS[k] == LS[i]:
                    yo,u,so = sorted([LS[i],LS[j],LS[k]])
                    ansL.append((yo,u,so))
    print(len(ansL))

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):
        if l[i] == l[j]:
            continue
        for k in range(j+1, n):
            if l[j] == l[k]:
                continue
            if l[k] >= (l[i]+l[j]):
                break
            ans += 1

print(ans)

Solution (Python):
import itertools

n = int(input())
l_list = list(map(int, input().split()))
ans = 0
for l1, l2, l3 in itertools.combinations(l_list, 3):
    li = [l1, l2, l3]
    if len(set(li)) != 3:
        continue
    if max(li) < sum(li) - max(li):
        ans += 1

print(ans)

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

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



ans = 0

for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            
            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):
def B():
    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, b, c = L[i], L[j], L[k]
                if len(set([a, b, c])) == 3 and not (a+b <= c or a+c <= b or b+c <= a):
                    count += 1
    return count
print(B())

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

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

L.sort()
cnt = 0

for i in range(N):
    for j in range(N):
        for k in range(N):    
            if i < j < k and L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and L[i]+L[j] > L[k]:
                cnt += 1
print(cnt)

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

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

ans = 0
for i in range(len(arr)):
    for j in range(i,len(arr),1):
        for k in range(j,len(arr),1):
            if arr[i] == arr[j] or arr[i] == arr[k] or arr[j] == arr[k]:
                continue
            if arr[k] < arr[i]+arr[j] and arr[i] < arr[j]+arr[k] and arr[j] < arr[i]+arr[k]:
                ans += 1

print(ans)

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

ans = 0
for i,j,k in p:
    if len(set([i,j,k])) == 3:
        if i + j > k  and j + k > i and k + i > j:
            ans += 1
print(ans)

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

ans = 0
for i,j,k in p:
    if i != j and j != k and k != i:
        if i + j > k  and j + k > i and k + i > j:
            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):
        if l[i] == l[j]:
            continue
        for k in range(j + 1, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            max_l = max(l[i], l[j], l[k])
            judge = (l[i] + l[j] + l[k] - max_l) - max_l
            if judge > 0:
                ans += 1

print(ans)

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

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):
        if l[i] == l[j]:
            continue
        s = l[i] + l[j]
        for k in range(j+1, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            if s > l[k]:
                ans += 1
print(ans)

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

n = 0

for i in range(0, len(L)):
    for j in range(i, len(L)):
        for k in range(j, len(L)):
            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    n += 1
print(n)

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

if len(L2) < 3:
  print("0")
  exit()

idx = dict()
for i in L:
  if i in idx:
    idx[i] = idx[i] + 1
  else:
    idx[i] = 1
    
def quicksort(arr):
  if len(set(arr)) <2:
    return arr
  center = arr.pop(0)
  left = []
  right = []
  for i in arr:
    if i < center:
      left.append(i)
    else:
      right.append(i)
  left = quicksort(left)
  right = quicksort(right)
  left.append(center)
  left += right
  return left

L2 = quicksort(L2)

res = 0
l = len(L2)

for i in range(l-2):
  for j in range(i+1,l-1):
    for k in range(j+1,l):
      if L2[i] + L2[j] > L2[k]:
        res += idx[L2[i]] * idx[L2[j]] * idx[L2[k]]

print(res)

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] and L[j] != L[k] and L[k] != L[i]:
        m = max(L[i], L[j], L[k])
        if m == L[i] and L[i] < L[j] + L[k]:
          ans += 1
        elif m == L[j] and L[j] < L[i] + L[k]:
          ans += 1
        elif m == L[k] and L[k] < L[j] + L[i]:
          ans += 1
print(ans)

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

Solution (Python):
n = int(input())
data = 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):
            i_ = data[i]
            j_ = data[j]
            k_ = data[k]
            
            if i_ != j_ and i_ != k_ and j_ != k_:
                
                if sum([i_, j_, k_]) - max(i_, j_, k_) > max(i_, j_, k_):
                    
                    count += 1
                
                

print(count)

Solution (Python):
n = int(input())
data = 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):
            i_ = data[i]
            j_ = data[j]
            k_ = data[k]
            
            if i_ != j_ and i_ != k_ and j_ != k_:
                
                if sum([i_, j_, k_]) - max(i_, j_, k_) > max(i_, j_, k_):
                    
                    count += 1
                else:
                    pass
                    

print(count)

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

Solution (Python):
from itertools import combinations
n = int(input())
l = list(map(int,input().split()))
c = combinations(l,3)
k=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:
		k+=1
print(k)

Solution (Python):
n = int(input())
original = list(map(int, input().split(" ")))
lengths = list(set(original))

count=0
lengths.sort()
for i in range(0, len(lengths)-2):
    a=original.count(lengths[i])
    for j in range(i+1,len(lengths)-1):
        b = original.count(lengths[j])
        for k in range(j+1,len(lengths)):
            if lengths[k]<lengths[i]+lengths[j]:
                c = original.count(lengths[k])
                count+=a*b*c

print(count)

Solution (Python):
n = int(input())
l = sorted(map(int, input().split()))
count = 0
for i in range(n-2):
  li = l[i]
  for j in range(i+1, n-1):
    lj = l[j]
    if li == lj:
      continue
    l_sum = li + lj
    for k in range(j+1, n):
      lk = l[k]
      if lj == lk:
        continue
      if lk < l_sum:
        count += 1
      else:
        break
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):
    if l[i]==l[j]:
      continue
    for k in range(j+1,n):
      if l[k]==l[i] or l[k]==l[j]:
        continue
      a=sorted([l[i],l[j],l[k]])
      if a[0]+a[1]>a[2]:
        ans+=1
print(ans)

Solution (Python):
def istriangle(a,b,c):
    if(a==b or b==c or c==a):
        return False
    
    elif(max(a,b,c)>= a+b+c - max(a,b,c)):
        return False
    
    else:return True
        

n = int(input())

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

count=0

for i in range(len(l)-2):
    for j in range(i+1,len(l)-1):
        for z in range(j+1,len(l)):
            if(istriangle(l[i],l[j],l[z])==True):
                count+=1
                
                
print(count)

Solution (Python):
import math

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

length = len(n_list)
count = 0
for i in range(length):
	for j in range(i+1, length):
		for k in range(j+1, length):
			if n_list[i] != n_list[j] and n_list[i] != n_list[k] and n_list[j] != n_list[k]:
				if abs(n_list[i]-n_list[j]) < n_list[k] and n_list[k] < n_list[i]+n_list[j]:
					count += 1
    
print(count)

Solution (Python):
n=int(input())
llist=list(map(int,input().split()))
counter=0
for i in range(n):
    for j in range(i+1):
        for k in range(j+1):
            tmp=[llist[i],llist[j],llist[k]]
            if len(tmp)==len(set(tmp)) and sum(tmp)-max(tmp)>max(tmp):
                counter += 1
print(counter)

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


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


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

    L.sort()
    count = 0

    for j in range(1, N - 1):
        rem = L[j + 1:]
        for i in range(j):
            if L[i] == L[j]:
                break

            count += bisect_left(rem, L[i] + L[j]) - bisect_right(rem, L[j])

    print(count)


if __name__ == "__main__":
    main()

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


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


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

            count += bisect_left(L[j + 1:], L[i] + L[j]) - bisect_right(L[j + 1:], L[j])

    print(count)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import bisect


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


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

            count += bisect.bisect_left(L[j + 1:], L[i] + L[j]) - bisect.bisect_right(L[j + 1:], L[j])

    print(count)


if __name__ == "__main__":
    main()

Solution (Python):
import sys


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


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

Solution (Python):
import sys


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


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

Solution (Python):
import sys
import bisect


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


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

Solution (Python):
import sys
import bisect


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


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

    L.sort()
    count = 0
    
    
    
    
    
    
    

    for j in range(1, N-1):
        rem = L[j+1:]
        for i in range(j):
            if L[i] == L[j]:
                break
            a = bisect.bisect_right(rem, L[j])
            b = bisect.bisect_left(rem, L[i] + L[j])
            count += b - a


    print(count)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import bisect

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


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

    L.sort()
    count = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            if L[i] == L[j]:
                continue
            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()

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

Solution (Python):
from math import *
from copy import *
from string import *				
from random import *
from sys import stdin,stdout
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
import math
import math
import time
from queue import Queue


def seive(n):
	l=[True]
	l=l*(n+1)
	for i in range(2,int(sqrt(n))+1):
		if(l[i]==True):
			val=i*i
			while(val<len(l)):
				l[val]=False
				val+=i
	prime=[]
	for i in range(2,len(l)):
		if(l[i]==True):
			prime.append(i)
	return prime

def dp(l,i,n,val,ans):
	if(i>=n or val<0):
		return 1000000
	elif(val==0):
		return 0
	else:
		if(ans[i]==1000000):
			ans[i]=min(min(1+dp(l,i+1,n,val-l[i],ans),1+dp(l,i,n,val-l[i],ans)),dp(l,i+1,n,val,ans))
		return ans[i]
from queue import Queue
def factors(n):
	l=[]
	for i in range(1,int(sqrt(n))+1):
		if(n%i==0):
			if(n//i==i):
				l.append(i)
			else:
				l.append(i)
				l.append(n//i)
	return l
def check1(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v-=1
def check2(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v+=1

def up(n):
	j=n-1
	while(j>0):
		if(n%j==0):
			break
		j-=1
	return j		
def fac(n):
	c=1
	i=1
	while(i<=n):
		c*=i
		i+=1
	return c
def check_happy(n):
	ss=set()
	print(n)
	while(n!=1):
		val=n
		s=0
		print(val)
		while(val!=0):
			s+=(val%10)**2
			val=val//10
		print(val)
		print("hi")
		if(val in ss):
			return False
		else:
			n=val
			ss.add(n)
	return True
def update(a,b):
	c=1
	val=a
	while(a<b):
		print(c,a)
		c+=c
		a+=a
	print(1)
	while(a>b):
		print()
		a-=val
		c-=1
	return c
import random as rand
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 

from itertools import permutations
def insertion_sort(arr):
	for i in range(len(arr)):
		j=i
		while(j>0):
			if(arr[j]<arr[j-1]):
				temp=arr[j]
				arr[j]=arr[j-1]
				arr[j-1]=temp
			j-=1
	return arr
def quick_sort(arr,low,high):
	i=low
	j=high
	
	while(i<j):
		if(arr[i]>arr[low] and arr[j]<arr[low]):
			temp=arr[i]
			arr[i]=arr[j]
			arr[j]=arr[i]
			i+=1
			j-=1
		elif(arr[i]<=arr[low]):
			i+=1
		elif(arr[j]>=arr[low]):
			j-=1
	print(i,j)
	toto=arr[j]
	arr[j]=arr[low]
	arr[low]=toto
	return j
def dodo(arr,low,high):
	if(low<high):
		val=quick_sort(arr,low,high)
		dodo(arr,low,val-1)
		dodo(arr,val+1,high)
def dp(arr,c,n,k,z,ans):
	if(k==0):
		return ans
	else:
		if(c==0):
			return dp(arr,c+1,n,k-1,z,ans+arr[c+1])
		elif(c==n-1):
			if(z==0):
				return 0
			else:
				return dp(arr,c-1,n,k-1,z-1,ans+arr[c-1])
		else:
			if(z==0):
				return dp(arr,c+1,n,k-1,z,ans+arr[c+1])
			else:
				return max(dp(arr,c+1,n,k-1,z,ans+arr[c+1]),dp(arr,c-1,n,k-1,z-1,ans+arr[c-1]))
def check(arr,val):
	a=-1
	for i in range(len(arr)):
		if(arr[i][len(arr[i])-1]==val):
			a=i
			break
	return a

def reverse(s,i,ans):
	if(i>=len(s)):
		return ans
	else:
		return reverse(s,i+1,s[i]+ans)
def update(arr,i,j,n,m):
    if(i>=0 and i<n and j>=0 and j<m):
        if(arr[i][j]==1):
            arr[i][j]==2
            return [i,j]
    return [-1,-1]
if __name__ == '__main__':
	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[k]+l[j]>l[i] and l[i]+l[k]>l[j] and l[i]!=l[j] and l[j]!=l[k] and l[i]!=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 L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[k]+L[j] > L[i]:
        if L[i] != L[j] and L[j] != L[k] and L[k]!=L[i]:
          ans+=1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
if n < 3:
    print(0)
else:
    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] and len(set([a[i],a[j],a[k]])) == 3:
                    ans += 1
    print(ans)

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

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

ans = 0
ans_l = []
for v in itertools.combinations(L,3):
    if v[0] != v[1] and v[0] != v[2] and v[1] != v[2]:
        if v[0] < v[1]+v[2] and v[1] < v[0]+v[2] and v[2] < v[0]+v[1]:
            ans += 1

print (ans)

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

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

Solution (Python):
n = int(input())
if n < 3:
  print(0)
  exit()
l = map(int,input().split())
l = sorted(l)
c = 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] and l[j] != l[k]:
        c += 1
print(c)

Solution (Python):


from itertools import combinations

def main():
  N = int(input())
  l = list(sorted(map(int,input().split())))
  combi = combinations(l,3)
  def judge(c):
    return c[0] < c[1] < c[2] and c[0] + c[1] > c[2]
  print(sum(judge(c) for c in combi))
  return

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

Solution (Python):
from itertools import combinations 

N = int(input())
L_list = list(map(int, input().split()))
ans = 0

for x, y, z in combinations(L_list, 3):
  
  if x == y or y == z or z == x:
    continue
  if x + y > z and y + z > x and z + x > y:
    ans += 1

print(ans)

Solution (Python):
from itertools import combinations 

N = int(input())
L_list = sorted(list(map(int, input().split())))
ans = 0

for x, y, z in combinations(L_list, 3):
  
  if x == y or y == z or z == x:
    continue
  if x + y > z and y + z > x and z + x > y:
    ans += 1

print(ans)

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

Solution (Python):
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for k in range(2,len(L)):
    for j in range(1,k):
        for i in range(0,j):
            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(map(int,input().split()))


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

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 = L[i], L[j], L[k]
            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)

Solution (Python):
a=int(input())
A = sorted(list(map(int, input().split())))

ans =0
for i in range(a):
  for j in range(i):
    for k in range(j):
      if(A[k] != A[j] and A[i] != A[j] and A[k] + A[j]>A[i]):
        ans+=1

print(ans)