Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
checklist = list(set(A))
countdic = {}
nCrdic = {}

for i in checklist:
    countdic[i] = A.count(i)
for key,value in countdic.items():
    nCrdic[key] = (value*(value-1))//2 if value > 1 else 0
for i in A:
    if countdic[i] > 2:
        ans = sum(nCrdic.values()) - nCrdic[i] + ((countdic[i]-1)*(countdic[i]-2))//2
    else: ans = sum(nCrdic.values()) - nCrdic[i]
    print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
A = list(map(int,input().split()))
countdic = Counter(A)
goukei = 0
ans = ''
for key,value in countdic.items():
    goukei += (value*(value-1))//2
for i in A:
    ans = goukei -(countdic[i]*(countdic[i]-1))//2 + ((countdic[i]-1)*(countdic[i]-2))//2
    print(ans)
### BUGGY CODE ###

import sys

def possible():
    print("POSSIBLE")
    sys.exit()

def main():
    N, M = map(int, input().split())
    hashdict = dict()
    for i in range(37):
        hashdict[i] = list()
    alist = list()
    for i in range(M):
        a, b = map(int, input().split())
        if a == 1:
            temp = b % 37
            hashdict[temp].append(b)
        if b == N:
            alist.append(a)

    for start in alist:
        temp = start % 37
        if start in hashdict[temp]:
            possible()
    print("IMPOSSIBLE")

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def possible():
    print("POSSIBLE")
    sys.exit()

def main():
    N, M = map(int, input().split())
    hashdict = dict()
    for i in range(1009):
        hashdict[i] = list()
    alist = list()
    for i in range(M):
        a, b = map(int, input().split())
        if a == 1:
            temp = b % 1009
            hashdict[temp].append(b)
        if b == N:
            alist.append(a)

    for start in alist:
        temp = start % 1009
        if start in hashdict[temp]:
            possible()
    print("IMPOSSIBLE")

if __name__ == "__main__":
    main()
### BUGGY CODE ###

N, K = list(map(int, input().split()))
H = sorted([int(input()) for _ in range(N)])

ans = []

for i in range(N-K+1):
    tree = H[i:i+K]
    ans.append(tree[-1]-tree[0])
print(min(ans))

### FIXED CODE ###

N, K = list(map(int, input().split()))
H = [int(input()) for _ in range(N)]
H.sort()
ans = []

for i in range(N-K+1):
    ans.append(H[i+K-1]-H[i])
print(min(ans))
### BUGGY CODE ###

n, p = map(int,input().split())
s = str(input())
mods = [(i*10)%p for i in range(p)]
sums = [0] * p

tmp = 0
dp = [[0]*p for i in range(n+1)]
for i in range(1,n+1):
    now = int(s[i-1])%p
    dp[i][now] += 1
    for j in range(p):
        dp[i][(mods[j]+now)%p] += dp[i-1][j]
#         tmp[(mods[j]+now)%p] += sums[j]
print(sum([dp[i][0] for i in range(n+1)]))
# print(*dp,sep="\n")

### FIXED CODE ###

n, p = map(int,input().split())
s = str(input())
ans = 0

if p == 2 or p == 5:
    for i in range(n):
        if int(s[i])%p == 0:
            ans += i+1
    print(ans)
    exit()

tmp = [0] * p
tmp[0] = 1
mod = 0
r = 1
for i in range(1,n+1):
    mod += (int(s[-i]) * r) % p
    mod %= p
    tmp[mod] += 1
    r *= 10
    r %= p

for i in tmp:
    ans += i*(i-1)//2

print(ans)
### BUGGY CODE ###

K = int(input())

from fractions import gcd
# return gcd(x, y)

d = {}
d2 = {}

def f(x, y, z):
    s = gcd(x, y)
    t = gcd(s, z)
    return t

ans = 0
for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            if i == j == k:
                ans += f(i, j, k)
            elif i == j or j == k:
                ans += 3 * f(i, j, k)
            else:
                ans += 6 * f(i, j, k)

print(ans)

### FIXED CODE ###

K = int(input())

from fractions import gcd
# return gcd(x, y)

d = {}

def f(x, y, z):
    # print(d)
    if d.get((x,y)):
        s = d[(x,y)]
    else:
        s = gcd(x, y)
        d[(x,y)] = s

    if d.get((s,z)):
        t = d[(s,z)]
    else:
        t = gcd(s,z)
        d[(s,z)] = t

    return t

ans = 0
for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            if i == j == k:
                ans += f(i, j, k)
            elif i == j or j == k:
                ans += 3 * f(i, j, k)
            else:
                ans += 6 * f(i, j, k)

print(ans)
### BUGGY CODE ###

N, A, B, C = map(int, input().split())

bamboos = []
for _ in range(N):
    l = int(input())
    bamboos.append(l)
    
ABC = [A, B, C]

import itertools
import sys

ans = sys.maxsize

for i in range(3, N+1):
    for bamboos_rearranged in itertools.permutations(bamboos, i):
        #print(bamboos_rearranged)
        for j in range(1, len(bamboos_rearranged)):
            for k in range(j+1, len(bamboos_rearranged)):
                bamboos_abc = (bamboos_rearranged[:j], bamboos_rearranged[j:k], bamboos_rearranged[k:])
                cost = 0
                for n, b in enumerate(bamboos_abc):
                    cost += (len(b) - 1) * 10
                    cost += abs(ABC[n] - sum(b))
                ans = min(ans, cost)
print(ans)
        
    

### FIXED CODE ###

N, A, B, C = map(int, input().split())

bamboos = []
for _ in range(N):
    l = int(input())
    bamboos.append(l)
    
import copy

def dfs(i, bs):
    if i == len(bamboos):
        #print(bs)
        if not bs['A'] or not bs['B'] or not bs['C']:
            return []
        return [bs]
    ret = []
    tmp = copy.deepcopy(bs)
    tmp['A'].append(bamboos[i])
    ret.extend(dfs(i+1, tmp))
    tmp = copy.deepcopy(bs)
    tmp['B'].append(bamboos[i])
    ret.extend(dfs(i+1, tmp))
    tmp = copy.deepcopy(bs)
    tmp['C'].append(bamboos[i])
    ret.extend(dfs(i+1, tmp))
    tmp = copy.deepcopy(bs)
    tmp['D'].append(bamboos[i])
    ret.extend(dfs(i+1, tmp))
    
    return ret

ABC = {'A': A, 'B': B, 'C': C}
bs_comb = dfs(0, {'A':[],'B':[],'C':[],'D':[]})

import sys
ans = sys.maxsize
for bs in bs_comb:
    cost = 0
    for abc in ['A', 'B', 'C']:
        cost += (len(bs[abc]) - 1) * 10
        cost += abs(sum(bs[abc]) - ABC[abc])
    ans = min(ans, cost)
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans = ans * a[i]
if ans > 10**18:
    print('-1')
else:
    print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
flag = 0
for i in range(n):
    ans = ans * a[i]
    if a[i] == 0:
        ans = 0
        break
    elif ans > 10**18 or a[i] > 10**18:
        if a[i:].count(0) > 0:
            ans = 0
            break
        else:
            ans = -1
            break
print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
modA = [a%M for a in map(int,input().split())]
ans = 0
for l in range(N):
  sumA = 0
  for r in range(l,N):
    sumA += modA[r]
    if sumA%M == 0: ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter
N,M = map(int,input().split())
A = list(map(int,input().split()))

sumA = [0] + [0]*N
for i in range(N):
  sumA[i] = (sumA[i-1]+A[i])%M

cnt = Counter(sumA).values()
ans = sum(i*(i-1)//2 for i in cnt)

print(ans)
### BUGGY CODE ###

import bisect
import copy
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ng=-1
ok=A[-1]*2+1
B=[0]*n
C=[0]*n
while ok-ng>1:
  mid=(ok+ng)//2
  d=0
  for i in range(n):
    c=n-bisect.bisect_right(A,mid-A[i],lo=0,hi=len(A))
    B[i]=c
    d=d+c
  if d<m:
    ok=mid
    C=copy.deepcopy(B)
  else:
    ng=mid
D=[0]
for i in range(n):
  D.append(D[-1]+A[n-i-1])
ans=0
for i in range(n):
  x=C[i]
  ans=ans+A[i]*x+D[x]
ans=ans+(m-sum(C))*ok
print(ans)

### FIXED CODE ###

import bisect
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ng=-1
ok=A[-1]*2+1
B=[[0]*n for k in range(2)]
ii=0
while ok-ng>1:
  mid=(ok+ng)//2
  d=0
  for i in range(n):
    c=n-bisect.bisect_right(A,mid-A[i],lo=0,hi=len(A))
    B[ii][i]=c
    d=d+c
  if d<m:
    ok=mid
    ii=(ii+1)%2
  else:
    ng=mid
D=[0]
for i in range(n):
  D.append(D[-1]+A[n-i-1])
ans=0
for i in range(n):
  x=B[(ii+1)%2][i]
  ans=ans+A[i]*x+D[x]
ans=ans+(m-sum(B[(ii+1)%2]))*ok
print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
list1 = []
for i in range(N):
    a,b = map(int,input().split()) 
    for j in range(b):
        list1.append(a)
list1.sort()
print(list1[K-1])

### FIXED CODE ###

N,K = map(int,input().split())
list1 = []
for i in range(N):
    list1.append(list(map(int,input().split())))
num = [0]*(10**5+1)
for j in range(N):
    num[list1[j][0]] += list1[j][1]
c = 0
d = 0
for k in range(10**5+1):
    c += num[k]
    if c >= K:
        d = k
        break
print(d)
### BUGGY CODE ###

n=int(input())
l=[int(i) for i in input().split()]
b=[]
if n%2==0:
    for i in range(n//2):
        b.append(l[2*i])
        b.insert(0,l[2*i+1])
else:
    for i in range(n//2):
        b.insert(0,l[2*i])
        b.append(l[2*i+1])
    b.insert(0,l[-1])
for i in b:
    print(i,end=' ')

### FIXED CODE ###

n=int(input())
l=[int(i) for i in input().split()]
if n%2==0:
  a=[l[2*i] for i in range(n//2)]
  b=[l[2*i+1] for i in range(n//2)]
  b=b[::-1]
  c=b+a
  for i in c:
    print(i,end=' ')
else:
  a=[l[2*i] for i in range(n//2+1)]
  b=[l[2*i+1] for i in range(n//2)]
  a=a[::-1]
  c=a+b
  for i in c:
    print(i,end=' ')
### BUGGY CODE ###

from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
for i in range(2, gcd//2 + 1):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break
if ans == 1 and gcd != 1:
    ans = 2
print(ans)

### FIXED CODE ###

from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
n = int(gcd**0.5) + 2
for i in range(2, n):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break
if gcd >= n:
    ans += 1
if ans == 1 and gcd != 1:
    ans = 2
    
print(ans)
### BUGGY CODE ###

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



def f(l, s):
    return s if l % s == 0 else f(s, l % s)
    
z = f(max(L), min(L))

for i in L:
    z=f(i,z)

for i in range(1,10**6):
    if max(L)>=i and i%z==0:
        print(i)
        exit()
print(z)

### FIXED CODE ###

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



def f(l, s):
    return s if l % s == 0 else f(s, l % s)
    
z = f(max(L), min(L))

for i in L:
    z=f(i,z)
ans=10000000000
for i in range(len(L)):
    if L[i]%z==0:
        pass
    elif L[i]%z<ans:
        ans=L[i]%z

if ans==10000000000:
    print(z)
else:
    print(ans)
### BUGGY CODE ###

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

b=[0 for _ in range(n)]
for i in range(n):
    y=a[n-i-1]
    b[n-i-1]=y
    divs = make_divisors(n-i)
    for x in divs:
        a[x-1] = a[x-1] ^ y
print(sum(b))
l=[]
for i in range(n):
    if b[i] == 1:
        l.append(i+1)
print(' '.join(map(str,l)))

### FIXED CODE ###

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

b=[0 for _ in range(n)]
for i in range(n):
    y=a[n-i-1]
    b[n-i-1]=y
    divs = make_divisors(n-i)
    for x in divs:
        a[x-1] = a[x-1] ^ y
print(sum(b))
l=[]
for i in range(n):
    if b[i] == 1:
        l.append(i+1)
print(' '.join(map(str,l)))
### BUGGY CODE ###

S = input()
N = len(S)
t = [1 for i in range(N)]
u = [1 for i in range(N)]
for p in range(10 ** 5):
  u[0] = t[1] * (S[1] == "L")
  for i in range(1, N - 1):
    u[i] = t[i-1] * (S[i-1] == "R") + t[i+1] * (S[i+1] == "L")
  u[N - 1] = t[N-2] * (S[N-2] == "R")
  t = u
  u = [1 for i in range(N)]                                       
print(*t)

### FIXED CODE ###

S = input()
N = len(S)
k = [0]
result = [0] * N

for i in range(N-1):
  if S[i] != S[i+1]:
    k.append(i+1)
l = [k[i+1] - k[i] for i in range(len(k) - 1)] + [N - k[-1]]

for i in range(1, len(k), 2):
  result[k[i]] += (l[i] + 1) // 2 + l[i-1] // 2
  result[k[i]-1] += l[i] // 2 + (l[i-1] + 1) // 2
print(*result)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import bisect
import itertools


def solve(N: int, L: "List[int]"):
    L.sort()
    ans = 0
    for i, l in enumerate(L[2:]):
        way2 = sorted([sum(x) for x in itertools.combinations(L[: 2 + i], 2)])
        ans += len(way2) - bisect.bisect_right(way2, l)
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import bisect
import itertools


def solve(N: int, L: "List[int]"):
    L.sort()
    L = tuple(L)
    ans = 0
    ans = sum([bisect.bisect_left(L, a+L[j]) - j - 1
               for i, a in enumerate(L[:-1], 1) for j in range(i, N)])
    print(ans)
    return


def main():
    def iterate_tokens():
        for sent in sys.stdin:
            for token in sent.split():
                yield token
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

X = int(input())
A = 1
K = 1
while K < X:
    A += 1
    K = A ** 5
S = A - 7
w = 0
while w != 1:
    Q = S ** 5 - X
    if Q < 0:
        B = 0
        while (Q < B**5):
            B -= 1
        if (Q == B**5):
            w += 1
        else:
            S += 1
        
    elif Q > 0:
        B = 0
        while (Q > B**5):
            B += 1
        if (Q == B**5):
            w += 1
        else:
            S += 1
print(S,B)

### FIXED CODE ###

X = int(input())
for i in range (240):
    for j in range (240):
        s = (i -120)**5 - (j -120)**5
        if s == X:
            A = i-120
            B = j -120
print(A,B)
### BUGGY CODE ###

N = int(input())
S =[]
times = {}
for i in range(N):
  S.append(input())

for m in range(N):
  count = 0
  for n in range(N):
    if S[m] == S[n]:
      count += 1
  times[S[m]] = count
max_k_list = [kv[0] for kv in times.items() if kv[1] == max(times.values())]
new_str_list = sorted(max_k_list)
for i in new_str_list:
  print(i)

### FIXED CODE ###

N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
m = max(times.items(), key = lambda x:x[1])[1]
a = []
for t in times.items():
	if(t[1]==m):
		a.append(t[0])
 
a.sort()
for t in a:
	print(t)
### BUGGY CODE ###

#ABC 094 Many Medians

numbers=int(input())
list_num=[int(i) for i in input().split()]
sorted_list=sorted(list_num)

median1=sorted_list[int(numbers/2)-1]
median2=sorted_list[int(numbers/2)]

for i in list_num:
    if sorted_list.index(i) <= numbers/2-1:
        print(median2)
    else:
        print(median1)

### FIXED CODE ###

numbers=int(input())
list_num=[int(i) for i in input().split()]
sorted_list=sorted(list_num)

median1=sorted_list[int(numbers/2)-1]
median2=sorted_list[int(numbers/2)]

for i in list_num:
    if i <= median1:
        print(median2)
    else:
        print(median1)
### BUGGY CODE ###

import copy
import math

N, K = list(map(int,input().split()))
As = list(map(int,input().split()))

sorted_As = sorted(As,reverse = True)
cut_As = copy.copy(sorted_As)
count_list = [0]*len(sorted_As)

for i in range(K):
    index = cut_As.index(max(cut_As))
    count = count_list[index]
    count_list[index] += 1
    cut_As[index] = sorted_As[index] / (count+2)

print(math.ceil(max(cut_As)))


### FIXED CODE ###

def judge(As,K,C):
    count = 0
    for i in range(len(As)):
        if As[i]%C == 0:
            m = As[i]//C - 1
        else:
            m = As[i]//C
        count += m
    if count <= K:
        return True
    else:
        return False

N, K = list(map(int,input().split()))
As = list(map(int,input().split()))

l = 0
r = max(As)
while(r-l>1):
    mid = (l+r)//2
    if judge(As,K,mid):
        r = mid -1
    else:
        l = mid + 1
if judge(As,K,r):
    print(r)
else:
    print(r+1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(200005)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, q = na()
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = na()
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

ps = [0] * n
for i in range(q):
    p, x = na()
    p -= 1
    ps[p] += x

ans = [0] * (n+1)

def dfs(cur, pre):
    global ps, ans, g
    ans[cur] = ans[pre] + ps[cur]
    for e in g[cur]:
        if e != pre:
            dfs(e, cur)

dfs(0, -1)

print(" ".join(map(str, ans[0:-1])))


### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, q = na()
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = na()
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

ps = [0] * n
for i in range(q):
    p, x = na()
    p -= 1
    ps[p] += x

stack = [0] * (n+1)
inds = [0] * (n+1)

sp = 0
stack[sp] = 0
sp += 1

while sp > 0:
    cur = stack[sp-1]
    if inds[sp-1] == len(g[cur]):
        sp -= 1
        continue
    if inds[sp-1] == 0 and sp > 1:
        ps[cur] += ps[stack[sp-2]]
    if sp == 1 or stack[sp-2] != g[cur][inds[sp-1]]:
        stack[sp] = g[cur][inds[sp-1]]
        inds[sp] = 0
        inds[sp-1] += 1
        sp += 1
        continue
    inds[sp - 1] += 1

print(" ".join(map(str, ps)))
### BUGGY CODE ###

def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())

    for _ in range(q):
        b, c = map(int, input().split())
        A = [c if a == b else a for a in A]
        print(sum(A))

resolve()

### FIXED CODE ###

def resolve():
    from collections import defaultdict
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    S = sum(A)
    d = defaultdict(int)
    for a in A:
        d[a] += 1

    for _ in range(q):
        b, c = map(int, input().split())
        k = d[b]
        d[b] -= k
        d[c] += k
        S += k * (c - b)
        print(S)

resolve()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(m):
        s,t=map(int,input().split())
        s-=1; t-=1;
        E[s].append(t)
    dp=[0]*n
    for v in range(n-2,-1,-1):
        res=0
        for nv in E[v]: res+=dp[nv]
        dp[v]=1+res/len(E[v])
    ans=dp[0] # 辺を消さなかった時のscore

    # 各 v に対し、削除する辺 v→u は、dp[u]が最大のもの
    for v in range(n-1):
        if(len(E[v])==1): continue
        u=max(*((dp[nv],nv) for nv in E[v]))[1]
        # vu を削除したときの期待値DPを行う
        dp2=[0]*n
        for x in range(n-2,-1,-1):
            res=0
            for nx in E[x]:
                if(x==v and nx==u): continue
                res+=dp2[nx]
            if(v!=x):
                dp2[x]=1+res/len(E[x])
            else:
                dp2[x]=1+res/(len(E[x])-1)
        ans=min(ans,dp2[0])
    print(ans)
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(m):
        s,t=map(int,input().split())
        s-=1; t-=1;
        E[s].append(t)
    dp=[0]*n
    for v in range(n-2,-1,-1):
        res=0
        for nv in E[v]: res+=dp[nv]
        dp[v]=1+res/len(E[v])
    ans=dp[0] # 辺を消さなかった時のscore

    # 各 v に対し、削除する辺 v→u は、dp[u]が最大のもの
    for v in range(n-1):
        if(len(E[v])==1): continue
        u=max(*((dp[nv],nv) for nv in E[v]))[1]
        # vu を削除したときの期待値DPを行う
        dp2=[0]*n
        for x in range(n-2,-1,-1):
            res=0
            for nx in E[x]:
                if(x==v and nx==u): continue
                res+=dp2[nx]
            if(v!=x):
                dp2[x]=1+res/len(E[x])
            else:
                dp2[x]=1+res/(len(E[x])-1)
        ans=min(ans,dp2[0])
    print(ans)
resolve()
### BUGGY CODE ###

a = int(input())
b = 0
count = 0
for i in range(a):
    i = i+1
    if a%i == 0:
        j = a//i
    if i*j == a:
        if count == 0:
            count += 1
            c = i
            d = j
        if count>0:
            if (c+d)>(i+j):
                c = i
                d = j
ans = c+d-2
print(ans)

### FIXED CODE ###

a = int(input())
b = 0
l = int(a**0.5)+1
count = 0
for i in range(l):
    i = i+1
    if a%i == 0:
        j = a//i
    if i*j == a:
        if count == 0:
            count += 1
            c = i
            d = j
        if count>0:
            if (c+d)>(i+j):
                c = i
                d = j
ans = c+d-2
print(ans)
### BUGGY CODE ###


def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    l = list(map(int,input().split()))
    dp = [[-float("INF")]*(n//2+1) for i in range(n+1)]
    dp[0][0] = 0
    dp[1][0] = 0
    dp[1][1] = l[0]
    for i in range(1,n):
        for j in range(max(0,i//2-1),min(i//2+2,n//2+1)):
            dp[i+1][j] = max(dp[i][j],dp[i-1][j-1]+l[i])
    print(dp[-1][-1])

if __name__ == "__main__":
    main()

### FIXED CODE ###

n = int(input())
def main():
    import sys
    input = sys.stdin.readline
    l = list(map(int,input().split()))
    dp = [[-float("INF")]*(3) for i in range(n+1)]
    dp[0][0] = 0
    dp[1][-1] = 0
    dp[1][1] = l[0]
    for i in range(1,n):
        
        dp[i+1][-1] = max(dp[i][0],dp[i-1][-1]+l[i])
        dp[i+1][0] = max(dp[i][1],dp[i-1][0]+l[i])
        dp[i+1][1] = dp[i-1][1]+l[i]
    print(max(dp[-1][0],dp[-1][-1]))

if __name__ == "__main__":
    main()
### BUGGY CODE ###

def main():
    A, B, C = map(int, input().split())
    K = int(input())
    n = 0
    while n < K:
        if C < B or C < A:
            C = C * 2
            n += 1
            if C > B > A:
                print('Yes')
                return
        elif B < A:
            B = B * 2
            n += 1
            if C > B > A:
                print('Yes')
                return
    print('No')
            
main()  



### FIXED CODE ###

def main():
    A, B, C = map(int, input().split())
    K = int(input())

    cnt = 0
    while A >= B:
        B = B * 2
        cnt += 1
    
    while B >= C:
        C = C * 2
        cnt += 1
    
    if cnt <= K:
        print('Yes')
    else:
        print('No')
main()
### BUGGY CODE ###

def main():
    N = int(input())
    edges = [int(i) for i in input().split()]

    ans = set()
    edges.sort()
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            for c in range(b + 1, N):
                if edges[a] < edges[b] + edges[c] and edges[b] < edges[c] + edges[a] and edges[c] < edges[a] + edges[b]:
                    ans.add((a, b, c))
    print(len(ans))


if __name__ == "__main__":
    main()

### FIXED CODE ###

import bisect


def main():
    N = int(input())
    edges = [int(i) for i in input().split()]
    edges.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_left(edges, edges[a] + edges[b])-b-1

    print(ans)


if __name__ == "__main__":
    main()