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

N = int(input())
l = list(map(int, input().split(" ")))
l.sort()
t = 0
for i in range(N-2):
    a = l[i]
    for j in range(i+1, N-1):
        b = l[j]
        low, upp = abs(b-a), a+b
        flag = 0
        for k in range(j+1, N):
            if low < l[k] < upp:
                t += 1
                flag = 1
            else:
                if flag == 1:
                    break
                else:
                    continue
print(t)

### FIXED CODE ###

from bisect import bisect_right
def main():
	N = int(input())
	L = list(map(int, input().split(" ")))
	L.sort()
	k = 0
	for i in reversed(range(2, N)):
		a = L[i]
		for j in reversed(range(1, i)):
			b = L[j]
			index = bisect_right(L, a-b, hi=j)
			k += j - index
	print(k)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

def solve():
    from bisect import bisect_left

    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    M = max(A) + max(B)
    K = len(bin(M)) - 2
    mask = (1 << K) - 1
    k = K - 1
    T = 1 << k
    ans = 0
    while k >= 0:
        for i in range(N):
            B[i] &= mask
        B.sort()
        bit = 0
        for a in A:
            a_ = a & mask
            T1 = bisect_left(B, T - a_)
            T2 = bisect_left(B, 2 * T - a_)
            T3 = bisect_left(B, 3 * T - a_)
            T4 = bisect_left(B, 4 * T - a_)
            bit += (T4 - T3) + (T2 - T1)
            bit &= 1
        ans += bit * (1 << k)
        k -= 1
        T >>= 1
        mask >>= 1

    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def solve():
    # from bisect import bisect_left
    import sys

    N = int(input())
    A = [int(x) for x in sys.stdin.readline().split()]
    B = [int(x) for x in sys.stdin.readline().split()]
    M = max(A) + max(B)
    K = len(bin(M)) - 2
    mask = (1 << K) - 1
    k = K - 1
    T = 1 << k
    ans = 0
    while k >= 0:
        for i in range(N):
            B[i] &= mask
            A[i] &= mask
        B = list(sorted(b & mask for b in B))
        A = list(sorted(a & mask for a in A))
        bit = 0
        T1, T2, T3 = 0, 0, 0
        for a in reversed(A):
            while T1 < N and a + B[T1] < T:
                T1 += 1
            while T2 < N and a + B[T2] < 2 * T:
                T2 += 1
            while T3 < N and a + B[T3] < 3 * T:
                T3 += 1
            # T1 = bisect_left(B, T - a, T1)
            # T2 = bisect_left(B, 2 * T - a, T2)
            # T3 = bisect_left(B, 3 * T - a, T3)
            # T4 = bisect_left(B, 4 * T - a, T4)
            bit += (N - T3) + (T2 - T1)
            bit &= 1
        ans += bit * T
        k -= 1
        T >>= 1
        mask >>= 1

    print(ans)


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

import numpy
n = input()
a =[int(e) for e in input().split(" ")]

a_n = numpy.array(a)
count = 0

for kk in range(10000):
    TF = a_n%2==0
    if any(TF):
        tmp = 0
        tmp_i = 0
        for i,j in enumerate(TF):       
            if j:
                if tmp <= a_n[i]:
                    tmp = a_n[i]
                    tmp_i = i
        a_n = a_n * 3
        a_n[tmp_i] = a_n[tmp_i]/6
        count += 1
    else:
        break
print(count)
 
             

### FIXED CODE ###

n = input()
a =[int(e) for e in input().split(" ")]

count = 0
for i in a:
    tmp = i
    for j in range(10000):
        if tmp%2 == 0:
            tmp /=2
            count += 1
        else:
            break

print(count)
### BUGGY CODE ###

s = input()
k = int(input())

n = len(s)

d = set()
for i in range(n):
    for j in range(i+1, n+1):
        tmp = s[i:j]
        d.add(tmp)
a = sorted(list(d))
print(a[k-1])


### FIXED CODE ###

s = input()
k = int(input())

n = len(s)

d = set()
for i in range(n):
    for j in range(i+1, min(i+k+1,n+1)):
        tmp = s[i:j]
        d.add(tmp)
a = sorted(list(d))
print(a[k-1])
### BUGGY CODE ###

import sys
input=sys.stdin.readline

N,M=map(int,input().split())

R=[1 for i in range(N+1)]
A,B=map(int,input().split())
R[A]=0
R[B]=0

L=[[]for i in range(N+1)]
L[A].append(B)
L[B].append(A)

for i in range(M-1):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)

l=[A]
P=A
#print(L)

for i in range(10**6):
    flag=0
    #print("P",L[P])
    for j in L[P]:
        #print("j",L,L[P],j,P)
        if R[j]==1:
            P=j
            R[j]=0
            l.append(j)
            flag+=1
            break
    if flag==0:
        break
#print(l)
r=[B]
P=B
for i in range(10**6):
    flag=0
    #print("P",L[P])
    for j in L[P]:
        #print("j",L,L[P],j,P)
        if R[j]==1:
            P=j
            R[j]=0
            r.append(j)
            flag+=1
            break
    if flag==0:
        break
#print(r)
l=l[::-1]
ans=l+r

ANS=str(ans[0])
for i in range(1,len(ans)):
    ANS+=" "+str(ans[i])
print(len(ans))
print(ANS)

### FIXED CODE ###

import sys
input=sys.stdin.readline

N,M=map(int,input().split())

R=[1 for i in range(N+1)]
A,B=map(int,input().split())
R[A]=0
R[B]=0

L=[[]for i in range(N+1)]
L[A].append(B)
L[B].append(A)

for i in range(M-1):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)

l=[A]
P=A
#print(L)

for i in range(10**6):
    flag=0
    #print("P",L[P])
    for j in L[P]:
        #print("j",L,L[P],j,P)
        if R[j]==1:
            P=j
            R[j]=0
            l.append(j)
            flag+=1
            break
    if flag==0:
        break
#print(l)
r=[B]
P=B
for i in range(10**6):
    flag=0
    #print("P",L[P])
    for j in L[P]:
        #print("j",L,L[P],j,P)
        if R[j]==1:
            P=j
            R[j]=0
            r.append(j)
            flag+=1
            break
    if flag==0:
        break
#print(r)
l=l[::-1]
ans=l+r

ANS=str(ans[0])
for i in range(1,len(ans)):
    ANS+=" "+str(ans[i])
print(len(ans))
print(ANS)
### BUGGY CODE ###

import itertools
n = int(input())
lis = [input() for _ in range(n)]
lis.sort()
choice = list(itertools.combinations(range(n), 3))
count = 0
for ch in choice:
    master = set(['M','A','R','C','H'])
    se = set([lis[ch[0]][0],lis[ch[1]][0],lis[ch[2]][0]])
    #print(master,se,master - se)
    if len(master - se) == 2:
        count += 1
print(count)


### FIXED CODE ###

import collections
import itertools
n = int(input())
li = []
for i in range(n):
    li.append(input()[0])

c = collections.Counter(li)
c_li = [c['M'],c['A'],c['R'],c['C'],c['H']]
#print(li,c,c_li)

count = 0
combination = list(itertools.combinations([0,1, 2, 3,4], 3))
for co in combination:
    tmp = 1
    for c in co:
        if c_li[c] == 0:
            tmp = 0
            break
        tmp *= c_li[c]
    count += tmp
print(count)
### BUGGY CODE ###

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

def rotate(l_2d):
    l_2d = np.array(l_2d)
    return (l_2d.T).tolist()


# check horizontal direction(done)
done = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if done[i][j] == 1 or s[i][j] == "#":
            continue
        l = 0
        k = j
        while k < w:
            if s[i][k] == ".":
                l += 1
            else:
                break
            k += 1
        for o in range(l):
            cnt[i][j+o] += l
            done[i][j+o] = 1


# check vertical direction
done = [[0] * w for _ in range(h)]
for j in range(w):
    for i in range(h):
        if done[i][j] == 1 or s[i][j] == "#":
            continue
        l = 0
        k = i
        while k < h:
            if s[k][j] == ".":
                l += 1
            else:
                break
            k += 1
        for o in range(l):
            cnt[i+o][j] += l
            done[i+o][j] = 1

print(max(list(map(max, cnt))) - 1)



### FIXED CODE ###

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

def rotate(l_2d):
    l_2d = np.array(l_2d)
    return (l_2d.T).tolist()


# check horizontal direction(done)
done = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if done[i][j] == 1 or s[i][j] == "#":
            continue
        l = 0
        k = j
        while k < w:
            if s[i][k] == ".":
                l += 1
            else:
                break
            k += 1
        for o in range(l):
            cnt[i][j+o] += l
            done[i][j+o] = 1


# check vertical direction
done = [[0] * w for _ in range(h)]
for j in range(w):
    for i in range(h):
        if done[i][j] == 1 or s[i][j] == "#":
            continue
        l = 0
        k = i
        while k < h:
            if s[k][j] == ".":
                l += 1
            else:
                break
            k += 1
        for o in range(l):
            cnt[i+o][j] += l
            done[i+o][j] = 1

print(max(list(map(max, cnt))) - 1)
### BUGGY CODE ###

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df[a].add(b)
        Df[b].add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db[c].add(d)
        Db[d].add(c)

    Q = []
    C = {}
    ANS = {}
    for i in range(1, n + 1):
        if C.get(i):
            continue

        C[i] = True
        Cin = {}
        Cin[i] = True
        Q.append(i)
        while len(Q) != 0:
            for f in Df[Q.pop(0)]:
                if not Cin.get(f):
                    Q.append(f)
                    C[f] = True
                    Cin[f] = True

        for k in Cin.keys():
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin.keys() & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df.get(a).add(b)
        Df.get(b).add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db.get(c).add(d)
        Db.get(d).add(c)

    Q = deque()
    C = set()
    ANS = {}
    for i in range(1, n + 1):
        if i in C:
            continue

        C.add(i)
        Cin = set()
        Cin.add(i)
        Q.appendleft(i)
        while len(Q) != 0:
            for f in Df.get(Q.pop()) - Cin:
                Q.appendleft(f)
                C.add(f)
                Cin.add(f)

        for k in Cin:
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

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

import sys
sys.setrecursionlimit(1000000)
a=['dream','dreamer','erase','eraser']
a=list(map(lambda x:x[::-1],a))
def check(c):
    if c=='':
        return True
    rt=False
    size=len(c)
    for i in a:
        if size>=len(i) and c[-len(i):]==i:
            rt=check(c[:-len(i)]) or rt
    return rt

print('YES' if check(input()[::-1]) else 'NO')


### FIXED CODE ###

a=['dream','dreamer','erase','eraser']
def check(c):
    if c=='':
        return True
    size=len(c)
    n=len(c)
    while n>0:
        tmp=n
        for i in a:
            #print(-n-len(i),-n)
            if size>=len(i) and c[n-len(i):n]==i:
                n-=len(i)
        if tmp==n:
            return False
    return True

print('YES' if check(input()) else 'NO')
### BUGGY CODE ###

n = int(input())
a_list = [int(input()) for _ in range(n)]

cnt=0
for i in set(a_list):
  cnt += a_list.count(i)%2
print(cnt)

### FIXED CODE ###

n = int(input())
a_list = [int(input()) for _ in range(n)]

my_set = set()
for i in a_list:
  if i in my_set:
    my_set.remove(i)
  else:
    my_set.add(i)
print(len(my_set))
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
ans = 0
i = 1
while a!=[]:
    if a[0]==i:
        i += 1
    else:
        ans += 1
    del a[0]
print(-1 if i==1 else ans)


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i+1-ans != a[i]:
        ans += 1
print(-1 if ans==N else ans)
### BUGGY CODE ###

import math
import fractions
n = int(input())


l = input().split()
for i in range(n):
    l[i] = int(l[i])
lc = 1

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


for i in range(n):
    lc = lcm(lc,l[i])
ans = 0
for i in range(n):
    ans+=lc//l[i]
    ans%=1000000007
print(ans)


### FIXED CODE ###

import math
import fractions
n = int(input())


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

lc = 1

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


for i in range(n):
    lc = lcm(lc,l[i])
ans = 0
for i in range(n):
    ans+=lc//l[i]

print(ans%1000000007)
### BUGGY CODE ###

N = int(input())
A = list(map(float,input().split()))
K = N//2 + 1
import sys
sys.setrecursionlimit(10000000)

def dfs(i,K):
    if (i,K) in cache: return cache[(i,K)]
    if K < 0: 
        cache[(i,K)] = 1
        return 1
    if i>=N: 
        cache[(i,K)] = 1
        return 1
    if len(A[i:]) < K: 
        res = (1-A[i])*dfs(i+1,K)
    elif len(A[i:]) == K: 
        res = A[i]*dfs(i + 1,K-1)
    else:
        res = A[i]*dfs(i+1,K-1) + (1-A[i])*dfs(i+1,K)
    cache[(i,K)] = res
    return res
cache={}
print(dfs(0,K))
            



### FIXED CODE ###

import collections
N = int(input())
A = list(map(float,input().split()))
K = N//2  + 1
dp = [[0 for _ in range(N + 1) ] for _ in range(N + 1)]
if N == 0: 
    print(0)
    exit
dp[0][0] = 1
ans = 0
for i in range(1,N+1):
    for j in range(i+1):
        if j - 1 < 0:
            dp[i][j] = dp[i-1][j]*(1-A[i-1])
        else:
            dp[i][j] = dp[i-1][j-1]*A[i-1] + dp[i-1][j]*(1-A[i-1])
for i in range(K,len(dp[N])):
        ans+=dp[N][i]
print(ans)
### BUGGY CODE ###

def sol():
    n=int(input())
    x=input()
    chk=0
    for i,j in enumerate(x[::-1]):
        if j=="1":
            chk+=2**i
    c,d={},{}
    ans=[]
    for i,j in enumerate(x[::-1]):
        p=pow(2,i)
        if j=="1": t=chk-p
        else: t=chk+p
        s=t
        cnt=0
        while t:
            if t not in c:
                pc=bin(t).count("1")
                c[t]=pc
            else:
                pc=c[t]
            t%=pc
            cnt+=1
            if t in d:
                cnt+=d[t]
                break
        if s not in d:
            d[s]=cnt
        ans.append(cnt)
    for i in ans[::-1]:
        print(i)

if __name__=="__main__":
    sol()


### FIXED CODE ###

n=int(input())
x=input()
chk0=chk1=chk2=0
b=x.count("1")
if b==1 and x=="1":
    print(0)
    exit()
elif b==1:
    for i in range(n):
        if i==n-1: print(2)
        elif x[i]=="0": print(1)
        else: print(0)
    exit()
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk1+=pow(2,i,b+1)
        if b>1: chk2+=pow(2,i,b-1)
        else: chk2=0
l=[]
for i,j in enumerate(x[::-1]):
    if b: a1=pow(2,i,b+1)
    else: a1=1
    if b>1: a2=pow(2,i,b-1)
    else: a2=1
    if j=="0":
        t=chk1+a1
    else:
        if b>1: t=chk2+b-1-a2
        else: t=0
    ans,f=0,1
    while t:
        if f:
            if j=="0": t%=(b+1)
            else: t%=(b-1)
            f=0
        else:
            t%=bin(t).count("1")
        ans+=1
    l.append(ans)
for i in l[::-1]:
    print(i)
### BUGGY CODE ###

N = int(input())
S = input()

Ans = 0
for i in range(N):
  s = S[i]
  a = 0
  b = 0
  L = ["R","G","B"]
  L.remove(s)
  for j in range(i+1,N):
    t = S[j]
    if s != t:
      if t == L[0]:
        a +=1
      else:
        b +=1
  Ans += a*b

for i in range(N):
  for j in range(i+1,N):
    s = S[i]
    t = S[j]
    k = 2*j-i
    if k <= N-1:
      u = S[k]
      if s != t and t != u and u != s:
        Ans -=1
print(Ans)

### FIXED CODE ###

N = int(input())
S = input()

L = [0,0,0]
for i in range(N):
    if S[i] == "R":
        L[0] +=1
    elif S[i] == "G":
        L[1] +=1
    else:
        L[2] +=1

Ans = L[0]*L[1]*L[2]

for i in range(N):
  s = S[i]
  n = min(N, (N+i)//2 + 1)
  for j in range(i+1,n):
    t = S[j]
    if s != t:
      k = 2*j-i
      if k <= N-1:
        u = S[k]
        if t != u and u != s:
          Ans -=1
print(Ans)
### BUGGY CODE ###

s = input()
K = int(input())

len_s = len(s)
str_list = []
for i in range(len_s):
    for j in range(1, len_s-i+1):
#        print(s[i:i+j])
        if(not(s[i:i+j] in str_list)):
            str_list.append(s[i:i+j])
        
#print(str_list)
s_str_list = sorted(str_list)
#print(s_str_list)
print(s_str_list[K-1])

### FIXED CODE ###

s = input()
K = int(input())

len_s = len(s)
str_list = []
for i in range(len_s):
    j_lim = min(len_s-i+1, 6)
    for j in range(1, j_lim):
#        print(s[i:i+j])
        if(not(s[i:i+j] in str_list)):
            str_list.append(s[i:i+j])
        
#print(str_list)
s_str_list = sorted(str_list)
#print(s_str_list)
print(s_str_list[K-1])
### BUGGY CODE ###

n, q = map(int, input().split())
S = input()
lr = []
ans = []
for i in range(q):
    LR = list(map(int, input().split()))
    lr.append(LR)

for i in range(q):
    s = S.count("AC", lr[i][0]-1, lr[i][1])
    print(s)

### FIXED CODE ###

n, q = map(int, input().split())
S = input()
lr = []
s = [0]*(n+1)
count = 0

for i in range(q):
    LR = list(map(int, input().split()))
    lr.append(LR)

for i in range(n-1):
    if S[i:i+2] == "AC":
        count += 1
        s[i+1] = count
    else:
        s[i+1] = s[i]
        
for i in range(q):
    print(s[lr[i][1] - 1] - s[lr[i][0] - 1])
### BUGGY CODE ###

n=int(input())

ans = {i for i in range(1,n+1)}

sum=n*(n+1)//2

for i in range(n,0,-1):
    if sum-i >n:
        ans.remove(i)
        sum -= i
    elif sum-i == n:
        ans.remove(i)
        break

for i in ans:
    print(i)


### FIXED CODE ###

n=int(input())

t=int(2*n**0.5)
ans = {i for i in range(1,t+1)}

sum=t*(t+1)//2


for i in range(t,0,-1):
    if sum-i >n:
        ans.remove(i)
        sum -= i
    elif sum-i == n:
        ans.remove(i)
        break

for i in ans:
    print(i)
### BUGGY CODE ###

N=int(input())
ans=0
A=list(map(int,input().split()))
for i in range(N-1):
    for j in range(i+1,N):
        ans+=A[i]*A[j]
print(ans%(10**9+7))

### FIXED CODE ###

N=int(input())
ans=0

A=list(map(int,input().split()))
zentai=sum(A)
ruiseki_WA=[]
kasu=0
for i in range(N):
    kasu+=A[i]
    ruiseki_WA.append(kasu)
hako=sum(A)
for i in range(N):
    ans+=A[i]*(hako-ruiseki_WA[i])   
print(ans%(10**9+7))
### BUGGY CODE ###

a,b,x=map(int,input().split())
ans=0
ans=(b-a+1)//x

for i in range(a+ans*x,b+1):
    if i%x==0:
        ans+=1
        break
        
print(ans)


### FIXED CODE ###

a,b,x=map(int,input().split())
ans=0
if (b-a+1)>=x:
    if a%x==0 and b%x==0:
        ans=((b-a)//x)+1
    elif not a%x==0 and not b%x==0:
        a=a+x-a%x
        b=b-b%x
        ans=((b-a)//x)+1
    elif not a%x==0 and b%x==0:
        a=a+x-a%x
        ans=((b-a)//x)+1
    elif a%x==0 and not b%x==0:
        b=b-b%x
        ans=((b-a)//x)+1
else:
    if a%x==0:
        ans=1
    else:
        if a+x-a%x<=b:
            ans=1
        else:
            ans=0
print(ans)
### BUGGY CODE ###

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

m = n//2
INF = 10**18
dp = [[-INF]*(m+1) for _ in range(n+1)]
for i in range(1, n+1):
    for j in reversed(range(1, m+1)):
        if j == 1:
            dp[i][j] = max(dp[i-1][j], A[i-1])
            continue
        if 0 <= i-2:
            dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+A[i-1])
print(dp[-1][m])


### FIXED CODE ###

from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
m = n//2
INF = 10**18
dp = [defaultdict(lambda: -INF) for _ in range(n+1)]
for i in range(1, n+1):
    L = i//2-1
    R = (i+1)//2+1
    for j in range(L, R):
        if j == 1:
            dp[i][j] = max(dp[i-1][j], A[i-1])
        elif 0 <= i-2 and 0 <= j <= m:
            dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+A[i-1])
print(dp[-1][m])
### BUGGY CODE ###

import sys

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = [A[0]]
    for a in A[1:]:
        for i in range(len(arr)):
            if a > arr[i]:
                arr[i] = a
                break
        else:
            arr.append(a)
    print(len(arr))
    
if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
import bisect
from collections import deque

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = deque()
    arr.append(A[0])
    for a in A[1:]:
        if a <= arr[0]:
            arr.appendleft(a)
        else:
            insert_index = bisect.bisect_left(arr, a)
            update = max(0, insert_index-1)
            arr[update] = a
    print(len(arr))
    
if __name__=='__main__':
    main()
### BUGGY CODE ###

import math
def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    
    return num


N = int(input())

ans = 0
for C in range(1,N):
  ans += num_divisors_trial_division(N-C)
  C += 1
 
print(ans)

### FIXED CODE ###

N = int(input())

ans = 0
for A in range(1,N):
  ans += (N-1) // A
print(ans)
### BUGGY CODE ###

##C - Sum of product of pairs
N = int(input())
A = list(map(int,input().split()))
import itertools
B = list(itertools.combinations(A,2))
print(sum (list(map(lambda x: x[0] * x[1], B))) % (10**9+7) )

### FIXED CODE ###

##C - Sum of product of pairs
##累積和
N = int(input())
A = list(map(int,input().split()))
S = sum(A)
ans = 0
for i in range(N-1):
    ans += A[i]*(S - A[i])
    S -= A[i]
print(ans % (10**9+7))
### BUGGY CODE ###

n = int(input())
A = sorted(map(int, input().split()))

B = [1 for _ in range(n)]

for i in range(n):
  if A[i]*2 > A[n-1] and A[i] <= A[n-1]:
    if i < n-1 and A[i] == A[i+1]:
      B[i] = 0
      B[i+1] = 0
      for j in range(n)[i+2:]:
        if A[j] == A[i]:
          B[j] = 0
        else:
          break
    else:
      continue
      
  c = 0
  if B[i] == 0:
    continue
  if i < n-1 and A[i] == A[i+1]:
    B[i] = 0
    B[i+1] = 0
    for j in range(n)[i+2:]:
      if A[j] == A[i]:
        B[j] = 0
      else:
        break
  while(A[i]*c <= A[n-1]):
    c += 1
    for j in range(n)[i+1:]:
      if A[j] == A[i]*c:
        B[j] = 0
print(sum(B))

### FIXED CODE ###

from collections import Counter
n = int(input())
A = sorted(map(int, input().split()))

c = Counter(A)

yes_or_no = [True for i in range(A[n-1]+1)]

for a in A:
  t = a*2
  while t <= A[n-1]:
    yes_or_no[t] = False
    t += a
ans = 0
for a in A:
  if c[a] == 1 and yes_or_no[a] == True:
    ans += 1
print(ans)
### BUGGY CODE ###

K = int(input())
if K % 2 == 0:
    print(-1)
else:
    r = 0
    rem = 7
    while (True):
        r += 1
        rem = rem % K
        if rem == 0:
            break
        rem = (rem * 10) + 7
    print(r)


### FIXED CODE ###

K = int(input())
if K % 2 == 0:
    print(-1)
else:
    r = 0
    rem = 7
    while (True):
        r += 1
        rem = rem % K
        if rem == 0:
            break
        if r > K:
            r = -1
            break
        rem = (rem * 10) + 7
    print(r)
### BUGGY CODE ###

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

a_dict = {}
for a in a_list:
    if not(a in a_dict):
        a_dict[a] = 0

    a_dict[a] += 1

for i in range(n):
    k = a_list[i]
    filtered = map(lambda x: x[1]-1 if x[0]
                   == k else x[1], a_dict.items())
    filtered = map(lambda x: x*(x-1)//2, filtered)
    print(sum(filtered))


### FIXED CODE ###

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

a_dict = {}
for a in a_list:
    if not(a in a_dict):
        a_dict[a] = 0
    a_dict[a] += 1
    
ans = sum(map(lambda x: x*(x-1)//2, a_dict.values()))

for i in range(n):
    k = a_list[i]
    before = a_dict[k]*(a_dict[k]-1) // 2
    after = (a_dict[k]-1)*(a_dict[k]-2) // 2
    print(ans - (before - after))