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

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

cnt = 0
for i in range(N):
    for j in range(N):
        if i != j and A[i] % A[j] == 0:
            break
        if i != j and A[j] >= A[i]:
            cnt += 1
            break
        if j == N-1:
            cnt += 1

print(cnt)


### FIXED CODE ###

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

ans = [False] * (Amax + 1)
for x in A:
    for j in range(x, Amax + 1, x):
        ans[j] += 1

print(sum(ans[i] == 1 for i in A))
### BUGGY CODE ###

from bisect import bisect_left
from collections import defaultdict

N, T, *A = map(int, open(0).read().split())

inf = 10 ** 9 + 7
dp = [inf] * (N + 1)
ctr = defaultdict(int)
for i in range(N):
    idx = bisect_left(dp, A[i])
    if idx == 0:
        dp = [inf] * (N + 1)
    dp[idx] = A[i]
    ctr[A[i] - dp[0]] += 1

print(min(T, ctr[max(ctr)]))


### FIXED CODE ###

from bisect import bisect_left
from collections import defaultdict

N, T, *A = map(int, open(0).read().split())

inf = 10 ** 9 + 7
dp = [inf] * (N + 1)
ctr = defaultdict(int)
for i in range(N):
    idx = bisect_left(dp, A[i])
    dp[idx] = A[i]
    if idx != 0:
        ctr[A[i] - dp[0]] += 1

print(ctr[max(ctr)])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1<<30)
def dfs(x,dis):
    for y in Tree[x]:
        if parent[x] != y:
            parent[y] = x
            dis[y] = dis[x]+1
            dfs(y,dis)

N,u,v = map(int,input().split())
Tree = [[] for _ in range(N+1)]
for i in range(N-1):
    A,B = map(int,input().split())
    Tree[A].append(B)
    Tree[B].append(A)
disT = [-1]*(N+1)
disA = [-1]*(N+1)
disT[u] = 0
disA[v] = 0
parent = [-1]*(N+1)
dfs(u,disT)
parent = [-1]*(N+1)
dfs(v,disA)
ans = 0
for i in range(1,N+1):
    if disT[i] <= disA[i]:
        ans = max(ans,disA[i]-1)
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1<<30)
def dfs(x,dis):
    for y in Tree[x]:
        if parent[x] != y:
            parent[y] = x
            dis[y] = dis[x]+1
            dfs(y,dis)

N,u,v = map(int,input().split())
Tree = [[] for _ in range(N+1)]
for i in range(N-1):
    A,B = map(int,input().split())
    Tree[A].append(B)
    Tree[B].append(A)
disT = [-1]*(N+1)
disA = [-1]*(N+1)
disT[u] = 0
disA[v] = 0
parent = [-1]*(N+1)
dfs(u,disT)
parent = [-1]*(N+1)
dfs(v,disA)
ans = 0
for i in range(1,N+1):
    if disT[i] <= disA[i]:
        ans = max(ans,disA[i]-1)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


N, Q = map(int, input().split())
 
class Node():
    def __init__(self):
        self.connected = []
        self.count = 0
 
 
 
def add_count(v, p):
    for c in G[v].connected:
        if c == p:
            continue
        G[c].count += G[v].count
        add_count(c, v)
 

G = [Node() for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].connected.append(b-1)
    G[b-1].connected.append(a-1)

for _ in range(Q):
    p, x = map(int, input().split())
    G[p-1].count += x

add_count(0, -1)

counts = [node.count for node in G]
print(*counts)



### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x
    
q = [(1,0)]
while q:
    x,parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y,x))

answer = ' '.join(map(str,value[1:]))
print(answer)
### BUGGY CODE ###

def solve(string):
    n, s = string.split()
    return str(min([s.count("W", 0, i) + s.count("E", i + 1) for i in range(int(n))]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


### FIXED CODE ###

def solve(string):
    n, s = string.split()
    n = int(n)
    es = {i for i, _s in enumerate(s) if _s == "E"}
    num_e = len(es)
    num_w = n - num_e
    count_e = 0
    count_w = 0

    ans = n
    for i, _s in enumerate(s):
        tmp = [count_e, count_w]
        if i in es:
            count_e += 1
        else:
            count_w += 1
        tmp += [num_e - count_e, num_w - count_w]
        ans = min(ans, tmp[1] + tmp[2])
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
### BUGGY CODE ###

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

for x in range(N+1):
    for y in range(N+1):
        for z in range(N+1):
            if 10000*x + 5000*y + 1000*z == Y and x+y+z==N:
                print(x, y, z)
                break
        else:
            continue
        break
    else:
        continue
    break

if x==N and y==N and z==N:
    print(-1, -1, -1)

### FIXED CODE ###

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

for x in range(N+1):
    for y in range(N-x+1):
        if 10000*x + 5000*y + 1000*(N-x-y) == Y:
            print(x, y, N-x-y)
            exit() # 処理を終わらせる
print(-1, -1, -1)
### BUGGY CODE ###

s = input()
li = list(s)

ans = 0
tmp = 0
length = len(li)
n = 0

while "ABC" in s:
    for i in range(n,length+1):
        if tmp == 0:
            if li[i] == "A":
                tmp += 1
                continue
            else:
                continue
        elif tmp == 1:
            if li[i] == "B":
                tmp += 1
                continue
            elif li[i] == "A":
                continue
            else:
                tmp = 0
                continue
        elif tmp == 2:
            if li[i] == "C":
                li[i] = "A"
                li[i-1] = "C"
                li[i-2] = "B"
                ans += 1
                s = "".join(li)
                tmp = 0
                n = i - 5
                break
            else:
                continue
print(ans)

### FIXED CODE ###

s = input()
 
ans = 0
s = s.replace("BC","D")
cnt_A = 0
 

for i in s:
    if i == "A":
        cnt_A += 1
    elif i == "D":
        ans += cnt_A
    else:
        cnt_A = 0

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

n, m = map(int, input().split())
money = 0
li = []

for i in range(n):
    li.append(list(map(int, input().split())))
li.sort()

while 0 < m:
    shop = li.pop(0)
    if m < shop[1]:
        money += m * shop[0]
        break
    money += shop[0] * shop[1]
    m -= shop[1]

print(money)


### FIXED CODE ###

n, m = map(int, input().split())
money = 0
li = []

for i in range(n):
    li.append(list(map(int, input().split())))
li.sort()

for j in range(n):
    shop = li.pop(0)
    if m < shop[1]:
        money += m * shop[0]
        break
    money += shop[0] * shop[1]
    m -= shop[1]

print(money)
### BUGGY CODE ###

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

root = [[pow(10,9)]*n for _ in range(n)]

from collections import deque

root=[0]*n

for _ in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if root[a]==0:
        root[a]=[b]
    else:
        root[a].append(b)

    if root[b]==0:
        root[b]=[a]
    else:
        root[b].append(a)
dist =[-1]*n
dist[0] = 0

q = deque([0])
prev=[-1] * n

while len(q)!=0:
    v = q.popleft()

    for j in root[v]:
        if dist[j]!=-1:
            continue
        else:
            dist[j] = dist[v] + 1
            prev[j] = v
            q.append(j)


for i in range(n):
    if i==0:
        print('Yes')
    else:
        print(prev[i]+1)


### FIXED CODE ###

n,m = map(int,input().split())
from collections import deque
r=[[] for i in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    r[a].append(b)
    r[b].append(a)

# dist =[-1]*n
# dist[0] = 0

q = deque([0])
prev=[-1] * n

while q:
    v = q.popleft()

    for j in r[v]:
        if prev[j]==-1:
            prev[j] = v
            q.append(j)
            # dist[j] = dist[v] + 1
            

for i in range(n):
    if i==0:
        print('Yes')
    else:
        print(prev[i]+1)
### BUGGY CODE ###

L,R=input().split()

mod=2019

for i in range(int(L),int(R)):
    for j in range(int(i)+1,int(R)+1):
        result=(i*j)%2019
        if mod>result :
            mod=result

print(mod)


### FIXED CODE ###

L,R=input().split()

mod=2019

for i in range(int(L),int(R)):
    for j in range(int(i)+1,int(R)+1):
        result=(i*j)%2019
        if mod>result :
            mod=result
        if mod == 0:
            break
    if mod == 0:
        break

print(mod)
### BUGGY CODE ###

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

hyouten = [0] * (N)

# 評点計算
for i in range(K-1, N):
    if i == K - 1:
        tmp = A[i]
        for j in range(1,K):
            tmp *= A[i-j]
    else:
        tmp //= A[i-K]
        tmp *= A[i]
    hyouten[i] = tmp

for i in range(K, N):
    if hyouten[i] > hyouten[i-1]:
        print('Yes')
    else:
        print("No")


### FIXED CODE ###

import sys
N, K = map(int, input().split())

def input():
    return sys.stdin.readline()[:-1]
A = list(map(int, input().split()))


for i in range(K, N):
    if A[i-K] < A[i]:
        print('Yes')
    else:
        print("No")
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
n,m = map(int, input().split())

uf = UnionFind(n)

for i in range(m):
    a,b = map(int, input().split())
    uf.union(a-1, b-1)
ans = 0
a = list(uf.all_group_members().values())
for i in range(len(a)):
    ans = max(ans,len(a[i]))
print(ans)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
n,m = map(int, input().split())

uf = UnionFind(n)

for i in range(m):
    a,b = map(int, input().split())
    uf.union(a-1, b-1)
ans = 0
roots = uf.roots()
cnt = []
for r in roots:
    cnt.append(uf.size(r))
cnt.sort(reverse=True)
ans = cnt[0]
print(ans)
### BUGGY CODE ###

from  heapq import heappush, heappop, heapify

n,m,s,t=map(int,raw_input().split())

nl=[ [ ] for j in range(n+1) ] 

for i in range(m):
	u,v,a,b=map(int,raw_input().split())
	nl[u].append( (v,a,b) )
	nl[v].append( (u,a,b) )

#print nl

v=2


def dij(v,type):
	d=[ float("inf") for i  in range(n+1)]
	d[v]=0

	Q=[]
	heappush(Q,v)

	while len(Q)>0:
		u=heappop(Q)
	#	print u, nl[u]
		for i in nl[u]:
			#print "i::",i
			v=i[0]
			yen=i[1]
			sunuku=i[2]
		#	print v,yen,sunuku,d
			if type=="y":alt=d[u]+yen
			elif type=="s":alt=d[u]+sunuku

			if d[v]> alt:
				d[v]=alt
				heappush(Q,v)
	return d

d_y=dij(s,"y")
d_s=dij(t,"s")

D=[]

for i in range(1,n+1):
	D.append( (d_y[i]+d_s[i], i ) ) 



D.sort(key=lambda x: x[0])


t=1
for x,N in D:
	for j in range(t,N+1):
		#print j,x
		print 10**15-x
		t+=1
		if t==n+1:
			quit()


### FIXED CODE ###

import heapq
 
N,M,S,T = map(int,input().split())
S,T = S-1,T-1
src = [tuple(map(int,input().split())) for i in range(M)]
 
es = [[] for i in range(N)]
for u,v,a,b in src:
    u,v = u-1,v-1
    es[u].append((v,a,b))
    es[v].append((u,a,b))
 
INF = float('inf')
cy = [INF] * N
cy[S] = 0
hq = [(0,S)]
heapq.heapify(hq)
while hq:
    cost,v = heapq.heappop(hq)
    for to,a,b in es[v]:
        if cost + a >= cy[to]: continue
        cy[to] = cost + a
        heapq.heappush(hq, (cy[to],to))
 
cs = [INF] * N
cs[T] = 0
hq = [(0,T)]
heapq.heapify(hq)
while hq:
    cost,v = heapq.heappop(hq)
    for to,a,b in es[v]:
        if cost + b >= cs[to]: continue
        cs[to] = cost + b
        heapq.heappush(hq, (cs[to],to))
 
ans = [INF]
for i in reversed(range(N)):
    tmp = cs[i] + cy[i]
    ans.append(min(ans[-1],tmp))
 
for a in reversed(ans[1:]):
    print(10**15 - a)
### BUGGY CODE ###

#coding: UTF-8

def is_prime(target_num):
    i = 2
    while i * i <= target_num:
        if target_num % i == 0:
            return False
        i += 1
    return True

def count_prime_numbers(target_num):
    prime_count = 0
    for i in range(2, target_num + 1):
        if is_prime(i):
            prime_count += 1
    return prime_count

while True:
    try:
        input_str = raw_input()
    except EOFError:
        break
    
    print count_prime_numbers(int(input_str))

### FIXED CODE ###

max_n = 999999
prime_list = [1] * (max_n + 1)

# 0, 1は素数ではない
prime_list[0:2] = [0, 0]

# 
for i in range(2, int(max_n**0.5) + 1):
    if prime_list[i] == 1:
        prime_list[i**2::i] = [0] * len(prime_list[i**2::i])

while True:
    try:
        n = int(input())
        print(sum(prime_list[:n + 1]))

    except EOFError:
        break
### BUGGY CODE ###

n =int(input())
A=[]
for I in range(n):
  moji=input()
  A.append(moji)
N=0
for i in range(n):
  a=list(A[i])
  a.sort()
  for s in range(i+1,n,1):
    b=list(A[s])
    b.sort()
    if a==b:
      N+=1
print(N)

### FIXED CODE ###

n =int(input())
A=[]
for I in range(n):
  moji=list(input())
  moji.sort()
  moji=''.join(moji)
  A.append(moji)
A.sort()
N=0
SUM=0
i=0
while True:
  if i==n-1:
    SUM=SUM+int(0.5*N*(N+1))
    break
  a=A[i]
  for s in range(i+1,n,1):
    b=A[s]
    if a==b:
      N+=1
      i+=1
    else:
      SUM=SUM+int(0.5*N*(N+1))
      N=0
      i=s
      break
print(SUM)
### BUGGY CODE ###

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

F = []
G = []
for i in range(1, N + 1):
    F.append(i + A[i - 1])
    G.append(i - A[i - 1])
F.sort()
G.sort()
for i in range(N):
    j = 0
    for j in range(N):
        if F[i] == G[j]:
            ans += 1
        if G[j] > F[j]:
            break

print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)
### BUGGY CODE ###

# E - Two Currencies

import heapq

n, m, s = map(int, input().split())
adj = {u: [] for u in range(1, n+1)}
for i in range(m):
    u, v, a, b = map(int, input().split())
    adj[u].append((v, a, b)) # to, 料金, 時間
    adj[v].append((u, a, b)) # to, 料金, 時間
exch = {}
for u in range(1, n+1):
    c, d = map(int, input().split())
    exch[u] = (c, d) # レート, 時間

max_silver = 50 * m    # これだけ持ってたらどの都市へも行ける

# n <= 50, m <= 100, max_silver <= 5000

# (都市,必要銀貨)を頂点とする最短経路問題

# 目的都市
for dest in range(2, n+1):
    # Dijkstra
    dist = {(dest, 0): 0}  # 開始頂点のみ距離0
    queue = [(0, dest, 0)]

    while len(queue) > 0:
        di, u, si = heapq.heappop(queue)
        # 用済みのデータ
        if (u, si) in dist and di > dist[(u, si)]:
            continue
        # 都市1に到達
        if u == 1 and si <= s:
            print(di)
            break

        # uに直接行ける各都市
        for v, a, b in adj[u]:
            if si + a > max_silver:
                break
            xsi = si + a
            if (v, xsi) not in dist or \
                dist[(v, xsi)] > di + b:
                dist[(v, xsi)] = di + b
                heapq.heappush(queue, (di + b, v, xsi))
        # 両替による遷移
        c, d = exch[u]
        xsi = max(si - c, 0)
        if (u, xsi) not in dist or \
            dist[(u, xsi)] > di + d:
            dist[(u, xsi)] = di + d
            heapq.heappush(queue, (di + d, u, xsi))


### FIXED CODE ###

# E - Two Currencies

import heapq

n, m, s = map(int, input().split())
adj = {u: [] for u in range(1, n+1)}
max_silver = 0
for i in range(m):
    u, v, a, b = map(int, input().split())
    adj[u].append((v, a, b)) # to, 料金, 時間
    adj[v].append((u, a, b)) # to, 料金, 時間
    max_silver += a # 全路線の料金の総和 (これ以上は不要)
exch = {}
for u in range(1, n+1):
    c, d = map(int, input().split())
    exch[u] = (c, d) # レート, 時間

s = min(s, max_silver) # max_silverまでで十分

# n <= 50, m <= 100, max_silver <= 5000

# (都市,所有銀貨)を頂点とする最短経路問題
# Dijkstra
dist = {(1, s): 0}  # 開始頂点のみ距離0
queue = [(0, 1, s)]
dmin = {1: 0} # dmin[u] = min(dist[(u, si)] for si)
nfin = 1      # 距離が決まった都市数

while len(queue) > 0:
    di, u, si = heapq.heappop(queue)
    # 用済みのデータ
    if (u, si) in dist and di > dist[(u, si)]:
        continue
    # 都市uの距離を保存
    if u not in dmin:
        dmin[u] = di
        nfin += 1
        if nfin >= n:  # 全都市の距離が決まった
            break
    # uから直接行ける各都市について
    for v, a, b in adj[u]:
        if si < a:  # 銀貨不足
            continue
        xsi = si - a
        if (v, xsi) not in dist or \
            dist[(v, xsi)] > di + b:
            dist[(v, xsi)] = di + b
            heapq.heappush(queue, (di + b, v, xsi))
    # 両替による遷移
    c, d = exch[u]
    xsi = min(si + c, max_silver)
    if (u, xsi) not in dist or \
        dist[(u, xsi)] > di + d:
        dist[(u, xsi)] = di + d
        heapq.heappush(queue, (di + d, u, xsi))

for u in range(2, n+1):
    print(dmin[u])
### BUGGY CODE ###

n, w = [int(e) for e in input().split()]
d = [[int(e) for e in input().split()] for i in range(n)]
t = {}
t[w] = 0
for i in range(n):
  keys = list(sorted(t.keys())) # sort しないと品物iを複数回ナップサックに詰める可能性がある
  tw, tv = d[i]
  for j in keys:
    nw = j - tw
    if nw < 0:
      continue
    nv = t[j] + tv
    if nw in t:
      if nv > t[nw]:
        t[nw] = nv
    else:
      t[nw] = nv
print(max(t.values()))

### FIXED CODE ###

n, w = [int(e) for e in input().split()]
d = [[int(e) for e in input().split()] for i in range(n)]
t = {}
t[w] = 0
for i in range(n):
  keys = list(sorted(t.keys()))
  tw, tv = d[i]
  for j in keys:
    nw = j - tw
    if nw < 0:
      continue
    nv = t[j] + tv
    if nw in t:
      if nv > t[nw]:
        t[nw] = nv
    else:
      t[nw] = nv
print(max(t.values()))
### BUGGY CODE ###

def rev(S):
  tmp = ''
  for i in range(len(S)):
    tmp = tmp + S[len(S)-1-i]
  return tmp

S = input()
Q = int(input())
tmp = S
for i in range(Q):
  query = input().split()
  if query[0] == '1':
    tmp = rev(tmp)
  elif query[0] == '2':
    if query[1] == '1':
      tmp = query[2] + tmp
    elif query[1] == '2':
      tmp = tmp + query[2]
print(tmp)

### FIXED CODE ###

s = input()
top = ''
n = int(input())
isReverse = False
for i in range(n):
    Q = input().split()
    if(Q[0] == '1'):
        isReverse = not isReverse
    else:
        if Q[1] == '1':
            if isReverse: s += Q[2]
            else: top += Q[2]
        else:
            if isReverse: top += Q[2]
            else: s += Q[2]
if isReverse: s = s[::-1] + top
else: s = top[::-1] + s
print(s)
### BUGGY CODE ###

N,Q=map(int,input().split())
S=input()
l=[0]*Q
r=[0]*Q
for i in range(Q):
  l[i],r[i]=map(int,input().split())
counter=[1 if (S[i]=="A")and(S[i+1]=="C") else 0 for i in range(len(S)-1)]
counter+=[0]
for j in range(Q):
  print(sum(counter[l[j]-1:r[j]-1]))

### FIXED CODE ###

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

import re
n, q = map(int,input().split())
s = input()
li = []
idx = -1

while True:
  idx = s.find('AC',idx+1)
  li.append(idx)
  if idx == -1:
    break
#print(li)
#cnt = 0
for i in range(q):
  cnt = 0
  l, r = map(int,input().split())
  for j in li:
    if j == -1:
      break
    elif l-1 <= j < r-1:
      cnt += 1
  print(cnt)

### FIXED CODE ###

n, q = map(int,input().split())
s = input()
li = [0]*(n+1)
for i in range(n):
  li[i+1] = li[i] + (1 if s[i:i+2]=='AC' else 0)
#print(li)
for i in range(q):
  l, r = map(int,input().split())
  print(li[r-1]-li[l-1])
### BUGGY CODE ###

n = int(input())
a = list(input().split())
b = []
for i in range(n):
    b.append(str(a.index(str(i+1))+1))
print(' '.join(b))


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i,val in enumerate(a):
    b[val-1] = i + 1
print(*b)
### BUGGY CODE ###

def d_ki():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N, Q = [int(i) for i in input().split()]

    tree = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = [int(i) for i in input().split()]
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    ans = [0] * N
    for _ in range(Q):
        p, x = [int(i) for i in input().split()]
        ans[p - 1] += x

    # 1次元配列だったら単純に累積和を取ればいいのだが、木なので
    # DFSをしなければならない
    def dfs(current, parent=-1):
        for child in tree[current]:
            if child == parent:
                continue
            ans[child] += ans[current]
            dfs(child, current)
    dfs(0)
    return ' '.join(map(str, ans))

print(d_ki())

### FIXED CODE ###

def d_ki():
    import sys
    input = sys.stdin.readline
    N, Q = [int(i) for i in input().split()]

    tree = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = [int(i) for i in input().split()]
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    ans = [0] * N
    for _ in range(Q):
        p, x = [int(i) for i in input().split()]
        ans[p - 1] += x

    # 1次元配列だったら単純に累積和を取ればいいのだが、木なので
    # DFSをしなければならない
    q = [0]
    is_visited = [False] * N
    while q:
        current = q.pop()
        is_visited[current] = True
        for child in tree[current]:
            if is_visited[child]:
                continue
            ans[child] += ans[current]
            q.append(child)
    return ' '.join(map(str, ans))

print(d_ki())
### BUGGY CODE ###

#import sys
#input = sys.stdin.readline
Q = 10**9 + 7
def main():
    N = int( input())
    A = list( map( int, input().split()))
    T = [[0]*60 for _ in range(N)]
    for i in range(N):
        a = A[i]
        for j in range(60):
            T[i][j] = a%2
            a //= 2
    ans = 0
    for i in range(60):
        plus = sum( [1 for j in range(N) if T[j][i] == 1])
        minus = N - plus
        ans = (ans + plus*minus%Q*pow(2,i,Q))%Q
    print(ans)
        
if __name__ == '__main__':
    main()


### FIXED CODE ###

#import sys
#input = sys.stdin.readline
Q = 10**9 + 7
def main():
    N = int( input())
    A = list( map( int, input().split()))
    T = [[0]*60 for _ in range(N)]
    P = [0]*60
    for i in range(N):
        a = A[i]
        for j in range(60):
            T[i][j] = a%2
            P[j] += a%2
            a //= 2
    ans = 0
    for i in range(60):
        plus = P[i]
        minus = N - plus
        ans = (ans + plus*minus%Q*pow(2,i,Q))%Q
    print(ans)
        
if __name__ == '__main__':
    main()