Harryxun/stf_run huggingface dataset:
//usr/bin/env picoc $0 - $@;exit
#include <stdio.h>
int main(){
  long long a,b,c,d,cnt;
  cnt = 0;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  //printf("%lld%lld%lld%lld",a,b,c,d);
  for(int i=a;i<=b;i++){
    if(i % c != 0 && i % d != 0){
      cnt++;
    }
  }
  printf("%lld\n",cnt);
}

### FIXED CODE ###

from fractions import gcd
a,b,c,d = map(int,input().split())
#cnt = 0
#lst = [i for i in range(a,b+1) if i%c!=0 and i%d!=0]
#print(len(lst))

c_d = int(c*d/gcd(c,d))
a -= 1
c2 = (b//c) - (a//c)
d2 = (b//d) - (a//d)
cd = (b//(c_d)) - (a//(c_d))
print(b-a - (c2+d2-cd))
#print(b-a-(b//c+b//d - a//c+a//d  - b//c_d - a//c_d))
"""
a-=1
a2 = a//c + a//d - a//(c*d)
print(b-a-(b//c + b//d - b//(c*d) - a2))
"""
"""
for i in range(a,b+1):
  if i % c != 0 and i % d != 0:
    cnt += 1
print(cnt)
"""
n=int(input())
a=list(map(int,input().split()))
count=1
if 0 in a:
  print(0)
  exit(0)
for i in a:
    count*=i
	if count>10**18:
    	print(-1)
        exit(0)
else:
    print(count)


### FIXED CODE ###

n = int(input())
lis = list(map(int,input().split()))
ans = 1
if 0 in lis:
  print(0)
  exit()
for num in lis:
  ans *= num
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)
x, y, a, b, c = map(int, input().split())
R = sorted(list(map(int, input().split())), reverse=True)
G = sorted(list(map(int, input().split())), reverse=True)
M = sorted(list(map(int, input().split())), reverse=True)

ans, r, g, m = 0, 0, 0, 0
mr = R[x - 1]
mg = G[y - 1]

for i in range(x + y):
    if r >= x:
        if m >= c:
            ans += G[g]
            g += 1
        elif G[g] > M[m]:
            ans += G[g]
            g += 1
        else:
            ans += M[m]
            m += 1
    elif g >= y:
        if m >= c:
            ans += R[r]
            r += 1
        elif R[r] > M[m]:
            ans += R[r]
            r += 1
        else:
            ans += M[m]
            m += 1
    elif R[r] >= G[g]:
        if m >= c:
            ans += R[r]
            r += 1
        elif R[r] > M[m]:
            ans += R[r]
            r += 1
        else:
            ans += M[m]
            m += 1
    elif R[r] < G[g] or r >= x:
        if m >= c:
            ans += G[g]
            g += 1
        if G[g] > M[m]:
            ans += G[g]
            g += 1
        else:
            ans += M[m]
            m += 1
print(ans)


### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
r = sorted(list(map(int, input().split())))[a - x:]
g = sorted(list(map(int, input().split())))[b - y:]
m = list(map(int, input().split()))

ans = sorted(r + g + m)
print(sum(ans[len(ans) - x - y:]))
a = input()
n = 2
m = 3
print(a + a ** n + a ** m)

### FIXED CODE ###

a = int(input())
n = 2
m = 3
print(a + a ** n + a ** m)
a,b,c = map(int,input().split())
print(f"{c} {a} {b}")

### FIXED CODE ###

a,b,c = map(int,input().split())
print("{} {} {}".format(c,a,b))
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
size = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, size + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

H, W, A, B = map(int,input().split())

ans = 0

for i in range(W-B):
    ans += cmb(H-A-1+(B+i), B+i, mod) * cmb(A-1+W-B-1-i, A-1, mod)
    ans %= mod

print(ans)

### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
size = 2*10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, size + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

H, W, A, B = map(int,input().split())

ans = 0

for i in range(W-B):
    ans += cmb(H-A-1+(B+i), B+i, mod) * cmb(A-1+W-B-1-i, A-1, mod)
    ans %= mod

print(ans)
n,k=input().split()
k=int(k)
x=n.replace(n[k-1],n[k-1].upper())
print(x)

### FIXED CODE ###

n,k=map(int,input().split())
s=input()
s=s[:k-1]+s[k-1].lower()+s[k:]
print(s)
def main():
    N = int(input())
    S = list(str(input()))
    sum = 0
    for i in range(0, N-2):
        si = S[i]
        for j in range(i, N-1):
            sj = S[j]
            k = 2*j -i
            sk = S[k]
            if j - i != k -j and si != sj and si != sk and sj != sk:
                sum += 1
    print(sum)


main()

### FIXED CODE ###

def main():
    N = int(input())
    S = list(str(input()))
    sum = S.count("R") * S.count("G") * S.count("B")
    for i in range(0, N-2):
        si = S[i]
        for j in range(i+1, N-1):
            sj = S[j]
            k = 2*j -i  # Nを超える
            if k < N:
                sk = S[k]
                #if j - i != k -j and si != sj and si != sk and sj != sk:
                if si != sj and si != sk and sj != sk:
                    sum -= 1
    print(sum)

    # 提出 #11871188


main()
N = int(input())

if N<=26:
	return chr(64+num)
elif N%26==0:
    return num2alpha(N//26-1)+chr(90)
else:
    return num2alpha(N//26)+chr(64+N%26)

  


### FIXED CODE ###

N = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(num2alpha(N).lower())
a,b = map(int,input().split())
print((a-1)＊(b-1))

### FIXED CODE ###

a,b = map(int,input().split())
print((a-1)*(b-1))
import sys
import numpy as np

read=sys.stdin.read
readline=sys.stdin.readline

def main():
  def mycount(x1,y1,x2,y2,mat,s):
    return mat[s,x2,y2]-mat[s,x1,y2]-mat[s,x2,y1]+mat[s,x1,y1]
  wb={'W':0,'B':1}
  n,k=map(int,readline().split())
  xyc=[l.split() for l in read().splitlines()]
  xyc=[[int(lst[0]) % (2*k),int(lst[1]) % (2*k),wb[lst[2]]] for lst in xyc]
  mat=np.zeros((2,4*k+1,4*k+1),dtype='int64')
  cand=np.zeros((2,2*k+1,2*k+1),dtype='int64')
  for i in range(4):
    for e in xyc:
      mat[e[2],e[0]+1+2*k*(i&1),e[1]+1+2*k*(i>>1&1)]+=1
  mat=np.cumsum(mat,axis=1)
  mat=np.cumsum(mat,axis=2)
 # for i in range(1,4*k+1):
 #   for j in range(1,4*k+1):
 #     mat[:,i,j]=mat[:,i,j]+mat[:,i-1,j]+mat[:,i,j-1]-mat[:,i-1,j-1]
  cand+=mat[0,k:3*k+1,k:3*k+1]+mat[0,:2*k+1,:2*k+1]-mat[0,k:3*k+1,:2*k+1]-mat[0,:2*k+1,k:3*k+1]\
  cand+=mat[0,2*k:4*k+1,2*k:4*k+1]+mat[0,k:3*k+1,k:3*k+1]-mat[0,2*k:4*k+1,k:3*k+1]-mat[0,k:3*k+1,2*k:4*k+1]\
  cand+=mat[1,2*k:4*k+1,k:3*k+1]+mat[1,k:3*k+1,:2*k+1]-mat[1,2*k:4*k+1,:2*k+1]-mat[1,k:3*k+1,k:3*k+1]\
  cand+=mat[1,k:3*k+1,2*k:4*k+1]+mat[1,:2*k+1,k:3*k+1]-mat[1,:2*k+1,2*k:4*k+1]-mat[1,k:3*k+1,k:3*k+1]
  #print(mat)
  print(np.max(cand))
  
if __name__=='__main__':
  main()
  
  
  


### FIXED CODE ###

import sys
import numpy as np

read=sys.stdin.read
readline=sys.stdin.readline

def main():
  wb={'W':1,'B':0}
  n,k=map(int,readline().split())
  xyc=[l.split() for l in read().splitlines()]
  xy=[[int(lst[0]) % (2*k),(int(lst[1])+k*wb[lst[2]]) % (2*k)] for lst in xyc]
  mat=np.zeros((k+1,2*k+1),dtype='int64')
  cand=np.zeros((k+1,k+1),dtype='int64')
  for e in xy:
    f0=e[0]>=k
    f1=e[1]>=k
    mat[e[0]-f0*k+1,e[1]+(-1)**f1*f0*k+1]+=1
  mat=np.cumsum(mat,axis=0)
  mat=np.cumsum(mat,axis=1)
  cand=mat[k,2*k]-mat[k,k:2*k+1]+mat[k,:k+1]\
       -np.reshape(mat[:k+1,2*k],(k+1,1))+2*mat[:,k:2*k+1]-2*mat[:,:k+1]
  print(max(np.max(cand),mat[k,2*k]-np.min(cand)))
  
if __name__=='__main__':
  main()
D = int(input())
c = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
#T = [int(input()) for i in range(D)]
SUM = 0
last = [0] * 28
for d in range(1, D + 1):
    i = S[d].index(max(S[d]))
    print(i)

### FIXED CODE ###

D = int(input())
c = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
#T = [int(input()) for i in range(D)]
SUM = 0
last = [0] * 28
for d in range(1, D + 1):
    i = S[d - 1].index(max(S[d - 1]))
    print(i + 1)
a = int(input())

b = int(input())


cross = int((a * b)/2)

if cross == 0:
    print("even")

if cross != 0:
    print("odd")

### FIXED CODE ###

a,b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
import collections

N,M = map(int,input().split())
if M == 0:
    print(N)
else:
    edge = np.array([input().split() for _ in range(M)], dtype = np.int8).T
    tmp = np.ones(M, dtype = np.int8).T
    graph = csr_matrix((tmp, (edge[:] -1)), (N, N))

    n, labels = connected_components(graph,directed = False, connection = 'weak')

    c = collections.Counter(labels)

    print(max(c.values()))

### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
import collections

N, M = map(int, input().split())
edge = np.array([input().split() for _ in range(M)], dtype=np.int64).T

if M == 0:
    print(1)
else:
    tmp = np.ones(M, dtype=np.int64).T
    graph = csr_matrix((tmp, (edge[:] - 1)), (N, N))

    n, labels = connected_components(graph)

    c = collections.Counter(labels)

    print(max(c.values()))
import copy
def dfs(cur_node, pre_node, Node_num, map, l):
    #全てのノードを見たとき

    if Node_num == N or cur_node <= 0 or cur_node >= N-1:
        return
    elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時
        return
    elif map[cur_node]==True:
        return

    map[cur_node]=True

    for i in range(N):
        if i != cur_node:
            dfs(i, cur_node, Node_num+1, map, l)


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

N = S[0]
M = S[1]


map = [False]*N
map[0] = True
map[N-1] = True
lst = []

for i in range(N):
    lst.append([0]*N)

for i in range(N):
    S = input()
    S = list(S.split())
    idx1 = int(S[0])
    idx2 = int(S[1])
    lst[idx1-1][idx2-1] = 1

graph_count = 0
#全探索
for i in range(1, N, 1):
    map_copy = copy.copy(map)
    lst_copy = copy.copy(lst)

    dfs(i, 0, 0, map_copy, lst_copy)
    count = 0
    for i in map_copy:
        if i == True:
            count = count + 1
    if count == N:
        graph_count = graph_count + 1

print(graph_count)


### FIXED CODE ###

import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)
s = input()
j = len(s)-2

if s.index('A')==0 and s[2:-1].count('C')==1:
    for i in s:
        j -= i.islower()

if j > 0:
    print('WA')
else:
    print('AC')

### FIXED CODE ###

s = input()

if s[0]=='A' and s[2:-1].count('C')==1 and (s[1:s.find('C')]+s[s.find('C')+1:]).islower():
    print('AC')
else:
    print('WA')
import sys
sys.setrecursionlimit(10**6)
from itertools import product
from collections import deque
import numpy as np
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, row in zip(range(h), grid):
            for j, val in zip(range(w), row):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, row)) for row in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

X = iter(open(0).readlines())
h, w = map(int, next(X).split())
ch, cw = map(int, next(X).split())
dh, dw = map(int, next(X).split())
dp = Grid([x.strip() for x in X], function=lambda x: 10**6 if x == '.' else -1)

def dfs(stack):
    if not stack:
        return
    x, y, d = stack[0]
    dp[y, x] = d
    stack2 = []
    while stack:
        x, y, d = stack.pop()
        if dp[y, x] < d:
            continue
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+dx, y+dy
            if dp.is_valid_xy(nx, ny) and dp[ny, nx] > d:
                dp[ny, nx] = d
                stack.append((nx, ny, d))
        for dx, dy in product(range(-2, 3), repeat=2):
            if abs(dx) + abs(dy) < 2:
                continue
            nx, ny = x+dx, y+dy                
            if dp.is_valid_xy(nx, ny) and dp[ny, nx] > d+1:
                dp[ny, nx] = d+1
                stack2.append((nx, ny, d+1))
    
    dfs([(x, y, d) for x, y, d in stack2 if dp[ny, nx] > d])

dfs([(cw-1, ch-1, 0)])
if dp[dh-1, dw-1] == 10**6:
    print(-1)
else:
    print(dp[dh-1, dw-1])

### FIXED CODE ###

from collections import deque
from itertools import product
h, w = list(map(int,input().split()))
sy, sx = list(map(int,input().split()))
gy, gx = list(map(int,input().split()))
sx, sy, gx, gy = sx-1, sy-1, gx-1, gy-1
 
G = [list(input()) for _ in range(h)]
D = [[10**6]*w for _ in range(h)]
D[sy][sx] = 0
Q = deque([(sy, sx)])
while Q:
    y, x = Q.pop()
    for dy, dx in product(range(-2, 3), repeat=2):
        ny, nx = y+dy, x+dx
        if dx==dy==0:
            G[y][x] = '#'
            continue
        elif ny<0 or h<=ny or nx<0 or w<=nx:
            continue
        elif G[ny][nx] == '#':
            continue
        elif abs(dy)+abs(dx)<=1:
            G[ny][nx] = '#'
            D[ny][nx] = D[y][x]
            Q.append((ny, nx))
        elif D[ny][nx] == 10**6:
            D[ny][nx] = D[y][x]+1
            Q.appendleft((ny, nx))
            
if D[gy][gx] == 10**6:
    print(-1)
else:
    print(D[gy][gx])
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

N = int(input())
A = [None] * N
for i in range(N):
    A[i] = int(input())

max_list = [-1]

for i in range(N):
    ok_list = [i for i, x in enumerate(max_list) if x < A[i]]
    if ok_list:
        max_list[ok_list[0]] = A[i]
    else:
        max_list.append(A[i])

ans = len(max_list)
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-

r = int(input())

ans = 3 * r * r

print(ans)
n, m = map(int, input().split())
sc = [map(int, input().split()) for i in range(m)]
s, c = [list(i) for i in zip(*sc)]

for i in range (10**(n-1),10**n):
    p = str(i)
    flag = 0
    for j in range(m):
        if p[s[j]-1] != str(c[j]):
            flag = 1
            break

    if flag == 0:
        print(i)
        flag = 2
        break

if flag != 2:
    print("-1")

### FIXED CODE ###

n, m = map(int, input().split())
sc = [map(int, input().split()) for i in range(m)]

flag = 0

if m != 0:
    s, c = [list(i) for i in zip(*sc)]


    if n == 1:
        for i in range (0,10):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break
    else:
        for i in range (10**(n-1),10**n):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break

if flag != 2:
    if m == 0:
        if n == 1:
            print("0")
        elif n == 2:
            print("10")
        else:
            print("100")
    else:
        print("-1")
import string
abc = list(string.ascii_lowercase)
li = [0 for a in range(len(abc))]

while True:
    a = raw_input()
    if a != '':
        for a in list(a):
            if a.lower() in abc:
                tmp = abc.index(a.lower())
                li[tmp] = li[tmp] + 1
    else:
        break

for a in range(len(abc)):
    print abc[a] + ' : ' + str(li[a])

### FIXED CODE ###

import string
az = list(string.ascii_lowercase)
li = [0 for a in range(len(az))]

while True:
    try:
        a = raw_input()
        for b in list(a):
            if b.lower() in az:
                tmp = az.index(b.lower())
                li[tmp] = li[tmp] + 1
    except:
        break

for c in range(len(az)):
    print az[c] + ' : ' + str(li[c])
print('Input x :')
cube = input('>> ')
print(cube ** 3)

### FIXED CODE ###

x = int(input())

print(x **3)
import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

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

l,r=a[0]*2,a[n-1]*2

while r-l>0:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md


p=0
cnt=0
ans=0

for q in range(n-1,-1,-1):
    while p<n and p>-1 and q<n and q>-1: 
        if a[q]+a[p]<=md: p+=1
        else: break
    cnt+=n-p
    ans+=a[q]*(n-p)*2
    if p==n: break


ans+=(m-cnt)*md
print(ans)

### FIXED CODE ###

import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

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

l,r=a[0]*2,a[n-1]*2
md=(r+l)//2
while r-l>0:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md

p=0
cnt=0
ans=0

for q in range(n-1,-1,-1):
    try:
        while p<n and a[q]+a[p]<=md:
            p+=1
    except:
        b=1
        while True:
            b+=1

    if p==n: break
    cnt+=n-p
    ans+=a[q]*(n-p)*2


ans+=(m-cnt)*md
print(ans)
n = int(input())
a = []
b = []
for j in range(n):
    l = list(map(int, input().split()))
    a.append(l[0])
    b.append(l[1])
 c = 0
for i in range(n-1, -1, -1):
    if (a[i]+c) % b[i] != 0:
        c += (b[i] - (a[i]+c) % b[i])
print(c)

### FIXED CODE ###

n = int(input())
a = []
b = []
for j in range(n):
    l = list(map(int, input().split()))
    a.append(l[0])
    b.append(l[1])
c = 0
for i in range(n-1, -1, -1):
    if (a[i]+c) % b[i] != 0:
        c += (b[i] - (a[i]+c) % b[i])
print(c)
N=input()
S=input()
K=int(input())
count=0
for s in S:
    if s==S[K]:
        pass
    else:
        S=S[:count] + '*' + S[count+1:]
    count+=1
print(S)


### FIXED CODE ###

N=int(input())
S=input()
K=int(input())
count=0
for s in S:
    if s==S[K-1]:
        pass
    else:
        S=S[:count] + '*' + S[count+1:]
    count+=1
print(S)
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>string to_string(pair<A, B> p);

template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {return '"' + s + '"';}

string to_string(const char* s) {return to_string((string) s);}

string to_string(bool b) {return (b ? "true" : "false");}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}

template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void test_case(vector <long> v, int n){
	sort(v.begin(),v.end());
	long ans = 0;	
	for (int i = 0; i < n - 2; i++){
		for (int j = i + 1; j < n - 1; j++){
			for (int k = j + 1; k < n; k++){
				if (v[i] != v[j] && v[j] != v[k] && v[i] != v[k] && v[k] < v[j] + v[i]){
					++ans;
					debug(i+1,j+1,k+1);
					debug(v[i],v[j],v[k]);
				}
			}                                     
		}
	}
	cout << ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <long> v(n);
	for (auto &x : v){
		cin >> x;
	}
	test_case(v,n);	
    return 0;
}





### FIXED CODE ###

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

l = sorted(l)

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

print(ans)
def solve_e(n, a_list):
    days = 0
    ind_list = [0] * n
    match_count = 0
    queue = list(range(n))
    stack = dict()
    while len(queue) > 0:
        days += 1
        new_queue = []
        for p in queue:
            if ind_list[p] < n - 1:
                q = a_list[p][ind_list[p]] - 1
                k = str(min(p, q)) + "_" + str(max(p, q))
                if k in stack.keys():
                    ind_list[p] += 1
                    ind_list[q] += 1
                    # print(days, p, q)
                    new_queue.append(p)
                    new_queue.append(q)
                    match_count += 1
                else:
                    stack[k] = 1
        queue = new_queue
    if match_count == n * (n - 1) // 2:
        return days - 1
    else:
        return -1


def test():
    n = 1000
    a_list = []
    for i in range(N):
        a_list.append(list(range(1, i + 1)) + list(range(i + 2, n + 1)))
    print(solve_e(n, a_list))


def main():
    n = int(input())
    a_list = []
    for _ in range(n):
        a_list.append(list(map(int, input().split())))
    print(solve_e(n, a_list))


if __name__ == "__main__":
    main()


### FIXED CODE ###

from bisect import bisect_right
from collections import defaultdict

s = list(input())
t = list(input())

L = len(s)
M = len(t)

ss = s * 2

ind_dict = defaultdict(list)
for i in range(2 * L):
    ind_dict[ss[i]].append(i)


def query_str(c, ind):
    if len(ind_dict[c]) == 0:
        return -1
    else:
        r = bisect_right(ind_dict[c], ind)
        return ind_dict[c][r]


res_total = 0
res = -1
for i in range(M):
    res = query_str(t[i], res)
    if res == -1:
        res_total = 0
        break
    if res >= L:
        res -= L
        res_total += L

if res == -1:
    print(-1)
else:
    print(res_total + res + 1)
A, B, K = map(int, input().split())
ans = set()
L = [i for i in range(A, B+1)]
for i in range(K):
  ans.add(L[i])
  ans.add(L[len(L) - 1 - i ])
ans = sorted(list(ans))
for x in ans:
  print(x)

### FIXED CODE ###

A, B, K = map(int, input().split())
ans = []
for i in range(K):
  ans.append(A + i)
for i in range(1,K+1):
  if B-(K-i) not in ans:
    ans.append(B-(K-i))
for x in ans:
  if A <= x and x <= B:
    print(x)
import numpy as np

N, K = list(map(int, input().split(' ')))
L = np.zeros(N).astype(int)
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(N):
    tot += L[i]
    if tot >= K:
        break
print(i+1)

### FIXED CODE ###

import numpy as np

L = np.zeros(10**5).astype(int)
N, K = list(map(int, input().split(' ')))
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(10**5):
    tot += L[i]
    if tot >= K:
        print(i+1)
        break