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

import copy

N = int(input())

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

center = N // 2 - 1

for i in range(N):
    B = copy.deepcopy(X)

    del B[i]

    B.sort(reverse=True)

    print(B[center])

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
center = N // 2
X_ = sorted(X)
ans = [X_[center-1], X_[center]]
center = sum(ans) / 2

for x in X:
    if x < center:
        print(ans[1])
    else:
        print(ans[0])
### BUGGY CODE ###

n, k = map(int, input().split())
s = input()

change_points = [i for i in range(n) if i == 0 or s[i-1] != s[i]]
max_ = 0
for i in range(len(change_points)):
    count = 0
    cur_k = 0
    for j in range(i, len(change_points)):
        p = change_points[j]
        if s[p] == '1':
            if j < len(change_points) - 1:
                count += change_points[j+1] - p
            else:
                count += len(s) - p
        else:
            if cur_k < k:
                cur_k += 1
                if j < len(change_points) - 1:
                    count += change_points[j+1] - p
                else:
                    count += len(s) - p
            else:
                break

    if count > max_:
        max_ = count
print(max_)


### FIXED CODE ###

n, k = map(int, input().split())
s = input()

change_points = [i for i in range(n) if i == 0 or s[i-1] != s[i]]
change_points.append(n)
max_ = 0
for i, p in enumerate(change_points):
    if i == len(change_points) - 1:
        continue
    if s[p] == '0':
        if i == 0:
            idx = min(i + 2 * k, len(change_points) - 1)
            tmp = change_points[idx] - p
        else:
            continue
    else:
        idx = min(i + 2 * k + 1, len(change_points) - 1)
        tmp = change_points[idx] - p
    if tmp > max_:
        max_ = tmp

print(max_)
### BUGGY CODE ###

import re
s = input()
words = ['dream', 'dreamer', 'erase', 'eraser']

while s != '':
    tmp = s
    s = re.sub(r'dream$', '', s)
    s = re.sub(r'dreamer$', '', s)
    s = re.sub(r'erase$', '', s)
    s = re.sub(r'eraser$', '', s)
    if s == '':
        print('YES')
    if tmp == s:
        print('NO')
        break


### FIXED CODE ###

s = input()
while s != '':
    tmp = s
    s = s.replace('eraser', '')
    s = s.replace('erase', '')
    s = s.replace('dreamer', '')
    s = s.replace('dream', '')
    if s == '':
        print('YES')
    if tmp == s:
        print('NO')
        break
### BUGGY CODE ###

N = int(input())
num = input()
X = int(num,2)
c = num.count('1')
def A(s):
    if s == 0:
        return 1
    return A(s%(bin(s).count('1'))) + 1
if c==1:
  for i in range(N):
    if num[i] == '1':
      print(0)
    elif i == N-1:
      print(2)
    else:
      print(1)
  exit()
Y = X
amari1 = X%(c+1)
amari2 = Y%(c-1)
for i in range(N):
    if num[i] == '1':
        print(A((amari2-2**(N-1-i))%(c-1)))
    else:
        print(A((amari1+2**(N-1-i))%(c+1)))

### FIXED CODE ###

N=int(input())
X=input()
Y=int(X,2)
Z=Y
C=X.count('1')
if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()
Y,Z=Y%(C+1),Z%(C-1)
def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))
 
for i in range(N):
  if X[i]=='1':
    print(1+f((Z-pow(2,N-i-1,C-1))%(C-1)))
  else:
    print(1+f((Y+pow(2,N-i-1,C+1))%(C+1)))
### BUGGY CODE ###

import numpy as np
import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2, int(n**0.5)+1):
        while not num%i: num //= i ; ans.append(i)
    if num != 1: ans.append(num)
    return col.Counter(ans)
    
n = int(input())
a = list(map(int,input().split()))

cnt = col.Counter()
for num in a:
    new = prime(num)
    for key,val in new.items():
        if val > cnt[key] : cnt[key] = val

LCM = 1
MOD = 10**9 + 7
for key,val in cnt.items(): LCM *= key**val

ans = 0
for num in a:
    b = LCM//num
    ans += b%MOD
    
print(ans%MOD)




### FIXED CODE ###

import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2, int(n**0.5)+1):
        while not num%i: num //= i ; ans.append(i)
    if num != 1: ans.append(num)
    return col.Counter(ans)
    
n = int(input())
a = list(map(int,input().split()))

cnt = col.Counter()
for num in a:
    new = prime(num)
    for key,val in new.items():
        if val > cnt[key] : cnt[key] = val

LCM = 1
MOD = 10**9 + 7
for key,val in cnt.items(): LCM *= key**val %MOD

ans = 0
for num in a:
    b = LCM * pow(num, MOD-2, MOD) #割るのではなく逆元をかける
    ans += b
    
print(ans%MOD)
### BUGGY CODE ###

N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for i in range(N)]

dp = [[10**15 for sum_v in range(10**5+100)] for i in range(N+100)]

for i in range(N):
    for sum_v in range(10**5+50):

        dp[0][0] = 0

        # i-1番目の品物を選ぶ場合
        if sum_v-items[i][1] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v],
                                 dp[i][sum_v-items[i][1]]+items[i][0])

        # i-1番目の品物を選ばない場合
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

ans = 0
for i in range(10**5+50):
    if dp[N][i] <= W:
        ans = i
print(ans)


### FIXED CODE ###

N,W=map(int,input().split())
items=[tuple(map(int,input().split())) for i in range(N)]
items.insert(0, (0,0))

v_max=sum([x[1] for x in items])

dp=[[10**13 for _ in range(v_max+1)] for _ in range(N+1)]
dp[0][0] = 0

for i in range(1,N+1):
    for j in range(v_max+1):
        # print(i,j)
        # take item
        if j-items[i][1]>=0:
            dp[i][j]=dp[i-1][j-items[i][1]]+items[i][0]
        
        dp[i][j]=min(dp[i][j],dp[i-1][j])

# print(dp[N])

ans=0
for i in range(v_max+1):
    if dp[N][i]<=W:
        ans=i

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

n = int(input())

result = 0

while n != 0:
    q = n // 10
    mod = n % 10

    result += mod
    n = q

if (result % 9) == 0:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

n = str(input())

count = 0
for v in list(n):
    count += int(v)

if (count % 9) == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

## dijkstraで解く
import heapq

H, W = map(int, input().split())
ch, cw = map(int, input().split())
dh_, dw_ = map(int, input().split())

fs = [input() for i in range(H)]

INF = float("inf")
N = 10**4
dps = [[INF]*W for i in range(H)]
dps[ch-1][cw-1] = 0
q = []
heapq.heapify(q)
heapq.heappush(q,(0, (ch-1)*N+(cw-1)))
while q:
    cnt, n  = heapq.heappop(q)
    h,w = divmod(n, N)
    if cnt > dps[h][w]:continue
    dps[h][w] = cnt
    # 歩いた
    for dh in range(-2,3):
        for dw in range(-2,3):            
            hn = h + dh
            wn = w + dw
            if not 0 <= wn < W: continue
            if not 0 <= hn < H: continue
            if fs[hn][wn] == "#": continue
            if dps[hn][wn] != INF:continue
            if abs(dh) + abs(dw) <= 1:
                heapq.heappush(q, (cnt, hn*N+wn))
            else:
                heapq.heappush(q, (cnt+1, hn*N+wn))

ans = dps[dh_-1][dw_-1]
print(ans if ans != INF else -1)


### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
ch, cw = map(int, input().split())
dh_, dw_ = map(int, input().split())

fs = []
for i in range(H):
    r = list(input())
    fs.append(r)

walks = [(-1,0),(1,0),(0,1),(0,-1)]
magics = []
for i in range(-2,3):
    for j in range(-2,3):
        if i==j==0:continue
        if (i,j) not in walks:
            magics.append((i,j))

INF = 1 << 50
dps = [[INF]*W for i in range(H)]
dps[ch-1][cw-1] = 0
q = deque([])
q.appendleft((ch-1,cw-1,0))
while len(q)>0:
    h,w,cnt = q.popleft()
    if cnt > dps[h][w]:continue
    dps[h][w] = cnt
    for dh, dw in walks:
        hn = h + dh
        wn = w + dw
        if 0<=hn<H and 0<=wn<W:
            if dps[hn][wn] != INF:continue
            if fs[hn][wn] == ".":
                q.appendleft((hn, wn, cnt))
    for dh, dw in magics:
        hn = h + dh
        wn = w + dw
        if 0<=hn<H and 0<=wn<W:
            if dps[hn][wn] != INF:continue
            if fs[hn][wn] == ".":
                q.append((hn, wn, cnt+1))

ans = dps[dh_-1][dw_-1]
print(ans if ans != INF else -1)
### BUGGY CODE ###

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

def f(a,b):
  re=[1]
  for i in range(2,min(a,b)//2):
    if a%i==0 and b%i==0:re.append(i)
  return re

def g(n):
  for i in range(2,n):
    if n%i==0:return False
  else:return True

ans=[g(i) for i in f(a,b)]
print(ans.count(True))


### FIXED CODE ###

import math,fractions
a,b=list(map(int,input().split()))

def f(n):
    a=[1]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<= n:
        if n%f==0:
            a.append(f)
            n//= f
        else:
            f+= 2
    if n!=1:
        a.append(n)
    return a

def g(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
 
ans=set(f(a))&set(f(b))
#print(ans)
print(len(ans))
### BUGGY CODE ###

def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

def GCD_of(a):
    """ Calc gcd of an array a"""
    allgcd = a[0]
    for value in a:
        allgcd = GCD(value, allgcd)
        if allgcd == 1:
            return allgcd
    return allgcd

N = int(input())
A = [ int(v) for v in input().split() ]

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

result = 0
for skip in range(N):
    tmp_max = GCD_of( [ A[i] for i in range(N) if not i == skip ] )
    if result < tmp_max: result = tmp_max
print(result)


### FIXED CODE ###

def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()


l_list = []
l = 0
for i in range(0, N):
    l = GCD(l, A[i])
    l_list.append( l )

r_list = []
r = 0
for i in range(-1, -(N+1), -1):
    r = GCD(r, A[i])
    r_list.append( r )

n = []    
for i in range(0, N):
    if i-1 < 0:
        l = 0
    else:
        l = l_list[i-1]
    if N-i-2 < 0:
        r = 0
    else:
        r = r_list[N-i-2]
    n.append(GCD(l, r))
print(max(n))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

seg = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

B = {}
for a in A:
    ind = seg[a]
    if not ind in B.keys():
        B[ind] = a
    else:
        if B[ind] < a:
            B[ind] = a

I = sorted(list(B.keys()))
#print(I)
Ap = []
def search(ind, remain, ret, l, maxl):
    if ind >= len(I):
        return False, ret, l
    #print(I[ind], remain, ret)
    a = I[ind]
    p = remain // a
    r = remain % a 
    if p == 0:
        return False, ret, l
    if r == 0:
        ret.append((a, p))
        l += p
        return True, ret, l
    for q in range(p-1, -1, -1):
        nowl = l
        r += a
        oldr = ret[:]
        ok, newr, newl = search(ind+1, r, oldr, nowl, maxl)
        if ok:
            newl += q
            newr.append((a, q))
            if ind == 0:
                if newl >= maxl:
                    maxl = newl
                    Ap.append(newr)
                continue
            return True, newr, newl
    if ind == 0:
        return False, Ap, l
    return False, ret, l

def main():

    only, Ls, l = search(0, N, [], 0, 0)
    #print(Ls)
    if only:
        Q = []
        for k, v in Ls:
            Q.extend([B[k]]*v)
        Q.sort(reverse=True)
        print(''.join([str(q) for q in Q]))
    else:
        anss = []
        for i, L in enumerate(Ls):
            P = []
            for k, v in L:
                P.append((B[k], v))
            P.sort(reverse=True)
            if i == 0:
                maxp = P[0][0]
            elif P[0][0] >= maxp:
                maxp = P[0][0]
            else:
                continue
            Q = []
            for p, v in P:
                Q.extend([p]*v)
            num = int(''.join([str(q) for q in Q]))
            anss.append(num)

        print(max(anss))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

NUM = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
INF = 10**14

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for a in A:
        c = NUM[a]
        if i + c <= N:
            dp[i+c] = max(dp[i+c], dp[i]+1)

D = dp[N]
ind = N
ans = ''
for _ in range(D):
    for a in A:
        c = NUM[a]
        if ind - c < 0: continue
        if dp[ind] == dp[ind-c] + 1:
            ind -= c
            ans += str(a)
            break
print(ans)
### BUGGY CODE ###

import sys
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, csgraph_from_dense

input = sys.stdin.readline


def main():
    N = int(input())
    edge = [[0] * N for j in range(N)]
    for _ in range(N - 1):
        a, b, c = [int(x) for x in input().split()]
        edge[a - 1][b - 1] = c
        edge[b - 1][a - 1] = c

    G = csgraph_from_dense(edge, null_value=0)
    d = johnson(G)

    Q, K = [int(x) for x in input().split()]
    for _ in range(Q):
        x, y = [int(x) for x in input().split()]
        print(int(d[x - 1][K - 1] + d[K - 1][y - 1]))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

input = sys.stdin.readline

d = []
ABC = []

sys.setrecursionlimit(10 ** 8)


def solve(i, dis):
    global d
    global ABC
    d[i] = dis

    for n, c in ABC[i]:
        if d[n] == -1:
            solve(n, dis + c)


def main():
    N = int(input())
    global ABC
    ABC = [[] for _ in range(N + 1)]
    global d
    d = [-1] * (N + 2)
    for _ in range(N - 1):
        a, b, c = [int(x) for x in input().split()]
        ABC[a - 1].append([b - 1, c])
        ABC[b - 1].append([a - 1, c])

    Q, K = [int(x) for x in input().split()]

    solve(K - 1, 0)

    for _ in range(Q):
        x, y = [int(x) for x in input().split()]
        print(d[x - 1] + d[y - 1])


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

# coding=utf-8
from collections import deque
n = int(input())
deque = deque()

for i in range(n):
    inp = list(input().split())
    if inp[0] == 'deleteFirst':
        deque.popleft()
    elif inp[0] == 'deleteLast':
        deque.pop()
    elif inp[0] == 'insert':
        deque.appendleft(inp[1])
    elif inp[0] == 'delete':
        if inp[1] in deque:
            deque.remove(inp[1])

print(*deque)

### FIXED CODE ###

# coding=utf-8
from collections import deque
n = int(input())
deque = deque()
input_lines = [input() for x in range(n)]

for i in range(n):
    inp = input_lines[i].split()
    if inp[0] == 'insert':
        deque.appendleft(inp[1])
    elif inp[0] == 'deleteFirst':
        deque.popleft()
    elif inp[0] == 'deleteLast':
        deque.pop()
    else:
        if inp[1] in deque:
            deque.remove(inp[1])

print(*deque)
### BUGGY CODE ###

import collections
def main():
	n, m = map(int, input().split())
	bridge = [[0, 0]]*m
	for i in range(m):
		bridge[i] = list(map(int, input().split()))
	inconveniences = [0]*(m+1)
	inconveniences[m] = (n*(n-1))//2
	islands = collections.defaultdict(list)
	stack = []
	for i in range(m-1, -1, -1):
		if inconveniences[i+1] == 0:
			break

		does_route_exist = False
		for island in islands[bridge[i][0]]:
			if island == bridge[i][1]:
				does_route_exist = True
				break

		if does_route_exist:
			inconvenience[i] = inconveniences[i+1]
			continue

		islands[bridge[i][0]].append(bridge[i][1])
		islands[bridge[i][1]].append(bridge[i][0])
		stack.append(bridge[i][0])

		is_visited = [False]*(n+1)
		total = 0
		for s in stack:
			is_visited[s] = True
			island_pair = 0
			queue = collections.deque([s])
			while queue:
				for island in islands[queue.popleft()]:
					if is_visited[island]:
						continue
					queue.append(island)
					is_visited[island] = True
					island_pair += 1

			total += (island_pair*(island_pair+1))//2

		inconveniences[i] = inconveniences[m] - total

	for i in range(1, m+1):
		print(inconveniences[i])

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
	n, m = map(int, input().split())
	bridge = [[0, 0]]*m
	for i in range(m):
		bridge[i] = list(map(int, input().split()))
	inconveniences = [0]*(m+1)
	inconveniences[m] = (n*(n-1))//2
	union_find = [[i, 0, 1] for i in range(n+1)]

	for i in range(m-1, -1, -1):
		if inconveniences[i+1] == 0:
			break
		if same(union_find, bridge[i][0], bridge[i][1]):
			inconveniences[i] = inconveniences[i+1]
			continue
		rx = root(union_find, bridge[i][0])
		ry = root(union_find, bridge[i][1])
		inconveniences[i] = inconveniences[i+1] - union_find[rx][2]*union_find[ry][2]
		unite(union_find, bridge[i][0], bridge[i][1])

	for i in range(1, m+1):
		print(inconveniences[i])

def root(union_find, val:int) -> int:
	if union_find[val][0] == val:
		return val
	return root(union_find, union_find[val][0])

def same(union_find, x:int, y:int) -> bool:
	rx = root(union_find, x)
	ry = root(union_find, y)
	return rx == ry

def unite(union_find, x:int, y:int):
	rx = root(union_find, x)
	ry = root(union_find, y)
	if rx == ry:
		return
	if union_find[rx][1] < union_find[ry][1]:
		union_find[rx][0] = ry
		union_find[ry][2] += union_find[rx][2]
	else:
		union_find[ry][0] = rx
		union_find[rx][2] += union_find[ry][2]
		if union_find[rx][1] == union_find[ry][1]:
			union_find[rx][1] += 1

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

N,K = map(int,input().split())
mod = 10**9+7
sum_min = 0
sum_max = 0
diff = 0
while K != N+2:
    for i in range(K):
        sum_min += i
    for k in range(N+1-K,N+1):
        sum_max += k
    diff += (sum_max-sum_min+1)
    sum_max = 0
    sum_min = 0
    K+= 1
diff = diff % mod
print(diff)

### FIXED CODE ###

N,K = map(int,input().split())
mod = 10**9+7
sum_min = 0
sum_max = 0
diff = 0
while K != N+2:
    sum_min = 1/2*K*(K-1)
    sum_max = 1/2*K*(2*N-K+1)
    diff += sum_max - sum_min+1
    K+= 1
diff = diff % mod
print(int(diff))
### BUGGY CODE ###

import itertools

n = int(input())
s = str(input())

r = {}
b = {}
g = {}
for i in range(len(s)):
    if s[i] == 'R':
        r[i] = s[i]
    elif s[i] == 'B':
        b[i] = s[i]
    else:
        g[i] = s[i]

ans = len(r) * len(b) * len(g)

nums = list(itertools.product(r.keys(), b.keys(), g.keys()))

for n in nums:
    num = list(n)
    num.sort()
    if num[2] - num[1] == num[1] - num[0]:
        ans -= 1

#print(r.keys())
#print(b.keys())
##print(g.keys())
#for i in r.keys():
#    for j in b.keys():
#        for k in g.keys():
#            if abs(k -j) == abs(j -i) or abs(k-i) == abs(i-j) or abs(k-j) == abs(k-i) :
#                ans -= 1


print(ans)

### FIXED CODE ###

import itertools
n = int(input())
s = str(input())
r = {}
b = {}
g = {}
for i in range(len(s)):
    if s[i] == 'R':
        r[i+1] = s[i]
    elif s[i] == 'B':
        b[i+1] = s[i]
    else:
        g[i+1] = s[i]
ans = len(r) * len(b) * len(g)
for i in r.keys():
    for j in b.keys():
        diff = abs(j-i)
        minb = min(i,j)-diff
        maxb = max(i,j)+diff
        if maxb in g.keys():
            ans -= 1
        if minb in g.keys():
            ans -= 1
        if((i+j)%2==0):
            if((i+j)//2 in g.keys()):
                ans -=1
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
d = [0]*n
cnt = 0
a.sort()

while a:
    res = a.pop(0)
    cnt += 1
    
    i = 0
    flag = False
    while True:
        if i >= len(a): break
        if a[i]%res==0:
            if a[i] == res:
                flag = True
            a.pop(i)
            i -= 1
        i += 1
    if flag: cnt -= 1

print(cnt)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = 0
d = [0]*(10**6+1)
a.sort()
for i in range(n):
    if d[a[i]]: continue
    cnt += 1
    if i != n-1 and a[i] == a[i+1]:
        cnt -= 1
    res = a[i]
    while res <= 10**6:
        d[res] = 1
        res += a[i]
print(cnt)
### BUGGY CODE ###

import numpy as np
h, w, d = map(int, input().split())
a = np.array([list(map(int, input().split())) for _ in range(h)])
q = int(input())
num = h * w
mass = np.array([[0, 0] for _ in range(num + 1)])
mp = np.zeros(num+1, dtype=int)
for i in range(h):
    for j in range(w):
        a_ij = a[i][j]
        mass[a_ij] = [i, j]
for i in range(d+1, num+1):
    mp[i] = mp[i-d] + np.sum(abs(mass[i]-mass[i-d]))

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


### FIXED CODE ###

import sys
input = sys.stdin.readline
h, w, d = map(int, input().split())
num = h * w
x = [0] * (num + 1)
y = [0] * (num + 1)
mp = [0] * (num + 1)
for i in range(h):
    for j, a in enumerate(map(int, input().split())):
        x[a], y[a] = [i+1, j+1]
for i in range(d+1, num+1):
    mp[i] = mp[i-d] + abs(x[i] - x[i-d]) + abs(y[i] - y[i-d])
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(mp[r]-mp[l])
### BUGGY CODE ###

keihin = int(input())

keihin_list = []
for i in range(keihin):
    now_keihin = input()
    if now_keihin not in keihin_list:
        keihin_list.append(now_keihin)

print(len(keihin_list))

### FIXED CODE ###

keihin = int(input())

keihin_list = []
for i in range(keihin):
    keihin_list.append(input())

print(len(set(keihin_list)))
### BUGGY CODE ###

import sys
from collections import deque
INFTY = 1<<30
a = [None] * 2000001
h = 0
ret = deque([])

def maxHeapify(i):
    global a, h
    l = 2 * i
    r = 2 * i + 1
    if l <= h and a[l] > a[i]:
        largest = l
    else:
        largest = i
    if r <= h and a[r] > a[largest]:
        largest = r
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        maxHeapify(largest)

def extract():
    global a, h
    if h < 1:
        return -INFTY
    maxv = a[1]
    a[1] = a[h]
    h -= 1
    maxHeapify(1)
    return maxv
    
def increaseKey(i, k):
    global a
    if k < a[i]:
        return
    a[i] = k
    while i > 1 and a[i//2] < a[i]:
        a[i], a[i//2] = a[i//2], a[i]
        i = i // 2

def insert(k):
    global a, h
    h += 1
    a[h] = -INFTY
    increaseKey(h, k)

i = 0
for com in sys.stdin.readlines():
    if com[0] == "i":
        insert(int(com[7:]))
    elif com[1] == "x":
        ret.append(extract())
    else:
        sys.stdout.writelines("\n".join([str(s) for s in ret]))
        print()

### FIXED CODE ###

import heapq
import sys

h = []

for com in sys.stdin.readlines():
    if com[0] == "i":
        heapq.heappush(h, -int(com[7:]))
    elif com[1] == "x":
        print(-heapq.heappop(h))
### BUGGY CODE ###

N = int(input())
aaa = list(map(int, input().split()))
zero = [0] * 61
one = [0] * 61
for a in aaa:
    for i in range(61):
        if a & (1<<i):
            one[i] += 1
        else:
            zero[i] += 1
ans = 0
MOD = 1_000_000_007
for i, o, l in zip(range(61), zero, one):
    ans += 2**i * o * l
    ans %= MOD
print(ans)


### FIXED CODE ###

N = int(input())
aaa = list(map(int, input().split()))
bbb = [format(a, '061b') for a in aaa]

zero = [0] * 61
one = [0] * 61
for i in range(61):
    s = ''.join(list(b[-(i+1)] for b in bbb))
    zero[i] = s.count('0')
    one[i] = s.count('1')
ans = 0
MOD = 1_000_000_007
for i, o, l in zip(range(61), zero, one):
    ans += 2**i * o * l
    ans %= MOD
print(ans)