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

#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = tuple(iim())

    d1 = dict()
    for ai in A:
        if ai in d1:
            d1[ai] += 1
        else:
            d1[ai] = 1

    aa = []
    items = d1.items()
    for ak in A:
        ans = 0
        for k, v in items:
            if k == ak:
                v -= 1
            if v > 1:
                ans += v * (v-1) // 2
        aa.append(ans)
    print(*aa, sep="\n")


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = tuple(iim())

    d1 = dict()
    for ai in A:
        if ai in d1:
            d1[ai] += 1
        else:
            d1[ai] = 1

    aa = []
    cnt = 0
    d2 = dict()
    for k, v in d1.items():
        v = v * (v-1) // 2
        cnt += v
        d2[k] = v

    for ak in A:
        ans = 0
        v = d1[ak] - 1
        v = v * (v-1) // 2
        aa.append(cnt-d2[ak]+v)
    print(*aa, sep="\n")


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

N=int(input())
A=[int(input()) for _ in range(N)]

dp=[1]*N
for i in range(N):
    for j in range(i):
        if A[j]<A[i]:
            dp[i]=max(dp[i],dp[j]+1)

print(sum([1 for v in dp if v==1]))


### FIXED CODE ###

N=int(input())
A=[int(input()) for _ in range(N)]

import bisect
B=[A[N-1]]
for i in range(N-2,-1,-1):
    if A[i]>=B[-1]:
        B.append(A[i])
    else:
        B[bisect.bisect_right(B,A[i])]=A[i]

print(len(B))
### BUGGY CODE ###

# import sys
# sys.setrecursionlimit(99999)

def find_index_by_value(a, val):
    for i, items in enumerate(a):
        if val in items:
            return i
    return -1


def num_reachable(n):
    return n * (n - 1) // 2


n, m = map(int, input().split())
edges = []

for _ in range(m):
    a, b = map(int, input().split())
    edges.append((a, b))

size = [1 for _ in range(n + 1)]
group = [i for i in range(n + 1)]


def find_group(x):
    p = x
    while True:
        pp = group[p]
        if pp == p:
            break
        p = pp
    return pp

ans = []
not_reachable = n * (n - 1) // 2
reachable_node = []
ans.append(not_reachable)

count = not_reachable
reachable = 0
for _ in range(m - 1):
    a, b = edges.pop()
    if count > 0:
        ra = find_group(a)
        rb = find_group(b)
        if rb != ra:
            s_ra = size[ra]
            s_rb = size[rb]
            new_size = s_ra + s_rb
            reachable += num_reachable(new_size) - num_reachable(s_ra) - num_reachable(s_rb)
            size[ra] = new_size
            group[rb] = ra
        count = not_reachable - reachable
    ans.append(count)

for _ in range(len(ans)):
    print(ans.pop())




### FIXED CODE ###

def find_index_by_value(a, val):
    for i, items in enumerate(a):
        if val in items:
            return i
    return -1


def num_reachable(n):
    return n * (n - 1) // 2


n, m = map(int, input().split())
edges = []

for _ in range(m):
    a, b = map(int, input().split())
    edges.append((a, b))

size = [1 for _ in range(n + 1)]
group = [i for i in range(n + 1)]


def find_group(x):
    c = []
    p = x
    while True:
        pp = group[p]
        if pp == p:
            break
        else:
            c.append(p)
            p = pp
    for i in c:
        group[i] = pp
    return pp

# find_group = lambda x: x if x == group[x] else find_group(group[x])

ans = []
not_reachable = n * (n - 1) // 2
reachable_node = []
ans.append(not_reachable)

count = not_reachable
reachable = 0
for _ in range(m - 1):
    a, b = edges.pop()
    if count > 0:
        ra = find_group(a)
        rb = find_group(b)
        if rb != ra:
            s_ra = size[ra]
            s_rb = size[rb]
            new_size = s_ra + s_rb
            reachable += num_reachable(new_size) - num_reachable(s_ra) - num_reachable(s_rb)
            size[ra] = new_size
            group[rb] = ra
        count = not_reachable - reachable
    ans.append(count)

for _ in range(len(ans)):
    print(ans.pop())
### BUGGY CODE ###

from collections import Counter
from itertools import product

n,m,q  = map(int,input().split())
rails=[tuple(map(int,input().split())) for i in range(m)]
qs=[tuple(map(int,input().split())) for i in range(q)]

xlist = [[0 for j in range(n)] for i in range(n)]
sumlist = [[0 for j in range(n+1)] for i in range(n)]
for (l,r),i in Counter(rails).items():
    xlist[l-1][r-1]=i

for (i,j) in product(range(n),range(n)):
    sumlist[i][j+1]=sum(xlist[i][0:j+1])


for (p,q) in qs:
    ans = 0
    for i in range(p-1,q):
        ans = ans+sumlist[i][q]-sumlist[i][p-1]
    print(ans)


### FIXED CODE ###

from collections import Counter
from itertools import product

n,m,q  = map(int,input().split())
rails=[tuple(map(int,input().split())) for i in range(m)]
qs=[tuple(map(int,input().split())) for i in range(q)]

xlist = [[0 for j in range(n)] for i in range(n)]
sumlist = [[0 for j in range(n+1)] for i in range(n)]
for (l,r),i in Counter(rails).items():
    xlist[l-1][r-1]=i


for (i,j) in product(range(n),range(n)):
    sumlist[i][j+1]=sum(xlist[i][0:j+1])


for (p,q) in qs:
    ans = 0
    for i in range(p-1,q):
        ans = ans+sumlist[i][q]-sumlist[i][p-1]
    print(ans)
### BUGGY CODE ###

import functools
import operator

multi = functools.partial(functools.reduce, operator.mul)

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

ans = multi(a)

if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

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

ans = 1

if 0 in a:
    print(0)
    exit()

for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()

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

N = int(input())
A = [] * 10 ** 18
A = list(map(int,input().split()))
anser = 1
for i in A:
    anser *= i
if anser > 10 ** 18:
    print("-1")
else:
    print(anser)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
anser = 1
if 0 in A:
    print("0")
    exit()
for i in A:
    anser *= i
    if anser > 10 ** 18:
        print("-1")
        exit()
print(anser)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import Counter
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = [i - 1 for i in a]
    ac = Counter(a)
    kaiten = [0] * n

    for i1 in range(n):
        if ac[i1] >= 1:
            kikan = n
            current = i1
            count = 0
            while kikan > 0:
                current = a[current]
                count += 1
                if current == i1:
                    kaiten[i1] = count
                    break
                kikan -= 1
    #print(kaiten)
    koko = 0
    go = 0
    while True:
        go += 1
        koko = a[koko]
        if kaiten[koko] > 0:
            break

    remain_go = (k - go) % kaiten[koko]
    while remain_go > 0:
        koko = a[koko]
        remain_go -= 1

    print(koko + 1)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n, k = map(int, input().split())
    a = [0]
    ta = list(map(int, input().split()))
    a += ta
    kaiten = [0] * (n + 1)
    count = 0
    koko = 1
    kaitenkikan = 0
    while k > 0:
        koko = a[koko]
        count += 1
        k -= 1
        if kaiten[koko] > 0:
            kaitenkikan = abs(count - kaiten[koko])
            break
        else:
            kaiten[koko] = count
    if k == 0:
        print(koko)
        sys.exit()
    k_remain = k % kaitenkikan
    if k_remain < 0:
        k_remain += kaitenkikan

    while k_remain > 0:
        koko = a[koko]
        k_remain -= 1

    print(koko)

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

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

ans=0
X=0
while X<=K:
    Y=0
    while Y<=K:
        Z=S-(X+Y)
        if 0<=Z and Z<=K:
            ans+=1
        Y+=1
    X+=1

print(ans)

### FIXED CODE ###

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

ans=0
for X in range(K+1):
    for Y in range(K+1):
        ans+=1*(0<=S-X-Y<=K)

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

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

DP = [[-10**9 for i in range((N+1)//2)] for i in range(N)]

DP[0][0] = A[0]
for i in range(1,N):
    DP[i][0] = max(DP[i-1][0],A[i])

for i in range(1,N//2-1):
    DP[2*i][i] = DP[2*(i-1)][i-1] + A[2*i]

for i in range(3,N):
    for j in range(i//2-2,(i+1)//2):
        DP[i][j] = max(DP[i-1][j],DP[i-2][j-1]+A[i])

print(DP[N-1][N//2-1])


### FIXED CODE ###

from collections import defaultdict

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

DP = defaultdict(lambda: -10**18)

DP[(0,0)] = A[0]

for i in range(1,N):
    for j in range((i+1)//2-1,(i+2)//2):
        if j == 0:
            DP[(i,0)] = max(DP[(i-1,0)],A[i])
        else:
            DP[(i,j)] = max(DP[(i-1,j)],DP[(i-2,j-1)]+A[i])

print(DP[(N-1,N//2-1)])
### BUGGY CODE ###


def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    for a in range(n):
        kou=A[a]*kou//gcd(A[a],kou)
    for a in range(n):
        if (kou//A[a])%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    for a in A:
        kou=a*kou//gcd(a,kou)
        if (kou//a)%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    na = [-1 for _ in range(2*n)]
    nk = n * k

    prevai = {}
    for i, _a in enumerate(a+a):
        if _a in prevai:
            na[prevai[_a]] = (i-prevai[_a])%n + 1
            if na[prevai[_a]] == 1:
                na[prevai[_a]] = n+1
        prevai[_a] = i

    doubling = [[0 for _ in range(n)] for _ in range(61)]
    for i in range(n):
        doubling[0][i] = na[i]
    for i in range(1, 61):
        for j in range(n):
            doubling[i][j] = doubling[i-1][j] + doubling[i-1][(j+doubling[i-1][j])%n]

    tmp = 0
    for i in range(60, -1, -1):
        if nk - tmp >= doubling[i][tmp%n]:
            tmp += doubling[i][tmp%n]

    if tmp == nk:
        return
    
    ans  = []
    adict = {}
    for i in range(tmp%n, n):
        if a[i] in adict and adict[a[i]] > 0:
            while True:
                _a = ans.pop()
                adict[_a] = 0
                if _a == a[i]:
                    break
        else:
            ans.append(a[i])
            adict[a[i]] = 1
    print(*ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    na = [-1 for _ in range(2*n)]
    nk = n * k

    prevai = {}
    for i, _a in enumerate(a+a):
        if _a in prevai:
            na[prevai[_a]] = (i-prevai[_a])%n + 1
            if na[prevai[_a]] == 1:
                na[prevai[_a]] = n+1
        prevai[_a] = i

    doubling = [[0 for _ in range(n)] for _ in range(61)]
    for i in range(n):
        doubling[0][i] = na[i]
    for i in range(1, 61):
        for j in range(n):
            doubling[i][j] = min(doubling[i-1][j] + doubling[i-1][(j+doubling[i-1][j])%n], nk+5)

    tmp = 0
    for i in range(60, -1, -1):
        if nk - tmp >= doubling[i][tmp%n]:
            tmp += doubling[i][tmp%n]

    if tmp == nk:
        return
    
    ans  = []
    adict = {}
    for i in range(tmp%n, n):
        if a[i] in adict and adict[a[i]] > 0:
            while True:
                _a = ans.pop()
                adict[_a] = 0
                if _a == a[i]:
                    break
        else:
            ans.append(a[i])
            adict[a[i]] = 1
    print(*ans)


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

n,k,q = list(map(int,input().split()))
a = [int(input()) for i in range(q)]
t = ["No"]*(n-max(a))
if k - q > 0:
        print(*["Yes"]*n,sep="\n")
        exit()
for i in range(1,max(a)+1):
    if k + a.count(i) - q > 0 :
        print("Yes")
    else:
        print("No")
print(*t,sep="\n")

### FIXED CODE ###

n,k,q = list(map(int,input().split()))
t = [0]*n
for i in range(q):
    t[int(input())-1] += 1

print(*["Yes" if k + i - q > 0 else "No" for i in t],sep="\n")
### BUGGY CODE ###

num = int(input())

dp = { 0: 1, 1: 1 }
def fibonacci(n):
  return dp[n] if n in dp else fibonacci(n - 1) + fibonacci(n - 2)

print(fibonacci(num))



### FIXED CODE ###

num = int(input())

dp = { 0: 1, 1: 1 }
def fibonacci(n):
  if not n in dp:
    dp[n] = fibonacci(n - 1) + fibonacci(n - 2)
  return dp[n]

print(fibonacci(num))
### BUGGY CODE ###

from collections import defaultdict
import bisect
def binary_search(s,val):
    if val > s[-1]:
        return False
    if val < s[0]:
        return False
    ind = bisect.bisect_left(s,val)
    return val == s[ind]
class UnionFind:
    def __init__(self,nodes):
        self.parents = {node : node for node in nodes}
    def root(self,x):
        if x == self.parents[x]:
            return x
        else:
            rt = self.root(self.parents[x])
            self.parents[x] = rt
            return rt
    def find(self,x,y):
        return self.root(x) == self.root(y)
    def union(self,x,y):
        self.parents[self.root(x)] = self.root(y)
    def get_sets(self):
        res = defaultdict(list)
        for node, parent in self.parents.items():
            res[self.root(node)].append(node)
        # return [*res.values()]
        return list(res.values())

N,M = map(int,input().split(' '))
p = list(map(int,input().split(' ')))

uf = UnionFind(range(1,N+1))

for i in [0]*M:
    x, y = map(int,input().split(' '))
    uf.union(x,y)

sets = uf.get_sets()

ans = 0
for s in sets:
    for n in s:
        if binary_search(s,p[n-1]):
            ans += 1
print(ans)





### FIXED CODE ###

from collections import defaultdict
class UnionFind:
    def __init__(self,nodes):
        self.parents = {node : node for node in nodes}
    def root(self,x):
        if x == self.parents[x]:
            return x
        else:
            rt = self.root(self.parents[x])
            self.parents[x] = rt
            return rt
    def find(self,x,y):
        return self.root(x) == self.root(y)
    def union(self,x,y):
        self.parents[self.root(x)] = self.root(y)
    def get_sets(self):
        res = defaultdict(list)
        for node, parent in self.parents.items():
            res[self.root(node)].append(node)
        # return [*res.values()]
        return list(res.values())

N,M = map(int,input().split(' '))
p = list(map(int,input().split(' ')))

uf = UnionFind(range(1,N+1))

for i in [0]*M:
    x, y = map(int,input().split(' '))
    uf.union(x,y)

ans = 0
for n in range(1,N+1):
    if uf.find(n,p[n-1]):
        ans += 1
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import math

# def f2(x, y, z, n):
#     return x*x+y*y+z*z+x*y+y*z+z*x

def f(x, y, z, n):
    if x*x+y*y+z*z+x*y+y*z+z*x == n:
        return True
    else:
        return False
def main():
    N = int(input())
    for n in range(1, N + 1):
        cnt = 0
        for x in range(1, 100):
            if x * x > n:
                break
            for y in range(x, 100):
                if x*x + y*y > n:
                    break
                for z in range(y, 100):
                    if x*x + y*y + z*z > n:
                        break
                    if f(x, y, z, n):
                        # print(x, end=' ')
                        # print(y, end=' ')
                        # print(z)
                        if x == y == z:
                            cnt += 1
                        else:
                            cnt += 3
        # print(n, end=': ')
        print(cnt)
    return
if __name__ == '__main__':
    main()

### FIXED CODE ###

# -*- coding: utf-8 -*-
import math

# def f2(x, y, z, n):
#     return x*x+y*y+z*z+x*y+y*z+z*x

def f(x, y, z, n):
    if x*x+y*y+z*z+x*y+y*z+z*x == n:
        return True
    else:
        return False
def main():
    N = int(input())
    for n in range(1, N + 1):
        cnt = 0
        for x in range(1, 100):
            if x * x > n:
                break
            for y in range(x, 100):
                if x*x + y*y > n:
                    break
                for z in range(y, 100):
                    if x*x + y*y + z*z > n:
                        break
                    if f(x, y, z, n):
                        # print(x, end=' ')
                        # print(y, end=' ')
                        # print(z)
                        if x == y == z:
                            cnt += 1
                        elif x != y and y != z and z != x:
                            cnt += 6
                        else:
                            cnt += 3
        # print(n, end=': ')
        print(cnt)
    return
if __name__ == '__main__':
    main()
### BUGGY CODE ###

S = int(input())
a, b = 0, 0
for i in range(1, S+1):
    if S % i == 0:
        if S // i <= 10**9:
            a, b = S // i, i
print("0 0 " + str(a) + " 0 1 " + str(b))


### FIXED CODE ###

import math
S = int(input())
a1, b2 = math.ceil(S**0.5), math.ceil(S**0.5)
c = a1*b2 - S

print("0 0 " + str(a1) + " " + str(c) + " 1 " + str(b2))
### BUGGY CODE ###

n,m = map(int,input().split())
cnt=[]
l=[int(input()) for _ in range(m)]
for i in range(n+1):
    cnt.append(0)
cnt[0]=1
l.sort()
for i in range(1,n+1):
    fl=False
    j=0
    while(j<m):
        t=l[j]
        if t==i:
            fl=True
            break
        if t>i:
            break
        j+=1
    if fl:
        cnt[i]=0
        continue
    else:
        cnt[i]+=cnt[i-1]
        if i>1:
            cnt[i]+=cnt[i-2]
#print(cnt)
print(cnt[n]%1000000007)



### FIXED CODE ###

n,m = map(int,input().split())
cnt=[]
l=[int(input()) for _ in range(m)]
for i in range(n+1):
    cnt.append(-1)
for i in range(m):
    cnt[l[i]]=0
cnt[0]=1
for i in range(1,n+1):
    if cnt[i]==0:
        continue
    else:
        cnt[i]=cnt[i-1]
        if i>1:
            cnt[i]+=cnt[i-2]
#print(cnt)
print(cnt[n]%1000000007)
### BUGGY CODE ###

N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
for _ in range(M):
    tmp=list(map(int,input().split()))
    A.extend([tmp[1]]*tmp[0])
A.sort()
print(sum(A[-N:]))

### FIXED CODE ###

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

for i in range(M):
    time,val=list(map(int,input().split()))
    try:
        all_c[val]+=time
    except:
        all_c[val]=time

tmp=list(all_c.keys())
tmp.sort(reverse=True)
total=0
sum_time=0
for i in tmp:
    if sum_time>=N:
        break
    sum_time+=all_c[i]
    if sum_time<N:
        total+=i*all_c[i]
    else:
        total+=i*(all_c[i]+N-sum_time)
print(total)
### BUGGY CODE ###

s = input()
dp,mod = [[0]*13 for i in range(len(s)+1)],10**9+7
dp[0][0],x = 1,[0,4,8,12,3,7,11,2,6,10,1,5,9]
for i in range(len(s)):
    if s[i]=="?":
        for k in range(10):
            for j in range(13): dp[i+1][j] = (dp[i+1][j]+dp[i][x[j-k]])%mod
    else:
        for j in range(13): dp[i+1][j] = dp[i][x[j-int(s[i])]]
print(dp[-1][5])

### FIXED CODE ###

s = input()
ans,mod = [0]*13,10**9+7
if s[0]=="?": ans = [1]*10+[0]*3
else: ans[int(s[0])] = 1
for i in s[1:]:
    dp = [0]*13
    for j in range(13): dp[j*10%13] = ans[j]%mod
    dp+=dp
    if i=="?":
        for j in range(13): ans[j] = sum(dp[j+4:j+14])
    else:
        for j in range(13): ans[j] = dp[j+13-int(i)]
print(ans[5]%mod)
### BUGGY CODE ###

import queue

n,m = map(int,input().split())

dis = [[] for i in range(n)]

for i in range(m):
    g1,g2,L =  map(int,input().split())
    dis[g1-1].append((g2-1,L))
    dis[g2-1].append((g1-1,-L))




geo = [0.5] * n

q = queue.Queue()


for i in range(n):
    if geo[i] == 0.5:
        q.put(i)
        while not q.empty():
            g1 = q.get()
            for g2,L in dis[g1]:
                if geo[g2] == 0.5:
                    geo[g2] = geo[g1] + L
                    q.put(g2)
                else:
                    if geo[g2] != geo[g1] + L:
                        print("No")
                        exit()
print("Yes")




### FIXED CODE ###

import collections
from collections import deque
import sys
input = sys.stdin.readline
 
def bfs(s):
    d = deque()
    d.append(s)
    dis[s]=0
    flag=True
    while len(d):
        x = d.popleft()
        for i,j in vec[x]:
            if dis[i] == INF:
                dis[i]=dis[x]+j
                d.append(i)
 
            else:
                if dis[i]==dis[x]+j:
                    continue
                else:
                    print('No')
                    exit()
    return flag
 
 
n,m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
vec= [[] for i in range(n)]
 
for i in range(m):
    vec[a[i][0]-1].append((a[i][1]-1,a[i][2]))
    vec[a[i][1]-1].append((a[i][0]-1,-a[i][2]))
 
INF=float('inf')
dis=[INF]*n
 
for i in range(n):
    if dis[i]==INF:
        bfs(i)
print('Yes')
### BUGGY CODE ###

import sys

s =  [0] + [ord(i) for i in sys.stdin.readline()] + [0, 0]

ret = 0
i = 0

while i < len(s) :
    if s[i] == 65 and s[i+1] == 66 and s[i+2] == 67 :
        s[i] += 1
        s[i+1] += 1
        s[i+2] -= 2

        ret += 1
        i -= 1
    else :
        i += 1

print(ret)


### FIXED CODE ###

s =  list(input())

ret = 0
i = 0
a = 0
bc = 0

while True :
    while i < len(s) and s[i] == 'A' :
        a += 1
        i += 1

    while i < len(s) - 1 and s[i:i+2] == ['B', 'C']  :
        bc += 1
        i += 2

    ret += a * bc

    bc = 0

    if i < len(s) and s[i] != 'A' :
        a = 0
        
    while i < len(s) and s[i] != 'A' :
        i += 1

    if i >= len(s) - 1 :
        break
    

print(ret)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
ac_list = [0]*n

for i in range(n-1):
  if s[i:i+2]=='AC':
    ac_list[i] += 1
  else:
    ac_list[i] += 0

for _ in range(q):
  l, r = map(int, input().split())
  print(sum(ac_list[l-1:r-1]))

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
### BUGGY CODE ###

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

ans=0

for i in range(60):
    cnt=len([i for i in range(n) if A[i]&1])
    ans +=2**i*cnt*(n-cnt)
    A=[A[i]>>1 for i in range(n)]

print(ans%(10**9+7))


### FIXED CODE ###

import numpy as np
mod=10**9+7
n=int(input())
A=np.array(list(map(int,input().split())))

ans=0

for i in range(60):
    cnt=np.count_nonzero(A&1)
    ans +=2**i*cnt*(n-cnt)
    A >>=1

print(ans%mod)