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

import copy

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

jumpIndex = -1

for i in range(N):
    if i < jumpIndex:
        print(tmpMax)
        continue
    tmp = copy.copy(A)
    tmp.remove(A[i])
    tmpMax = max(tmp)
    for j in range(i + 1, N):
        if A[i] == tmpMax:
            jumpIndex = i
    print(tmpMax)

### FIXED CODE ###

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

maxNum = max(A)
index = -1
for i in range(N):
    if A[i] == maxNum:
        index = i

for i in range(N):
    if i != index:
        print(maxNum)
        continue
    else:
        A.remove(maxNum)
        print(max(A))
### BUGGY CODE ###

from operator import mul
from functools import reduce

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

def cmb(n, r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

mod = 10**9+7

ans = (2**n -1 - cmb(n, a) - cmb(n, b))%mod

print(ans)

### FIXED CODE ###

def modComb(n, r, mod):
    nume = 1
    deno = 1
    for i in range(r):
        nume = nume*(n-i) % mod
        deno = deno*(i+1) % mod
    return nume*pow(deno, mod-2, mod) % mod
 
n, a, b = map(int, input().split())

mod = 10**9+7

ans = (pow(2, n, mod) -1 - modComb(n, a, mod)
       - modComb(n, b, mod)) % mod

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

import sys
from operator import itemgetter
def main():
	inputs = sys.stdin.readline
	N, Q= map(int,inputs().split())
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while e[0] > d:
			if cont == True:
				print(mini-(mini//1000000001)*1000000002)
			else:
				mini = min(kouho)
				print(mini-(mini//1000000001)*1000000002)
			cont = True
			q = q + 1
			if q > Q-1:
				flag = True
				break
			d = int(inputs())
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			cont = False
	for t in [None]*(Q-q):
		print(-1)
main()

### FIXED CODE ###

import sys
from operator import itemgetter
def main():
	inputs = sys.stdin.readline
	N, Q= map(int,inputs().split())
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while e[0] > d:
			if cont == True:
				print(mini-(mini//1000000001)*1000000002)
			else:
				mini = min(kouho)
				print(mini-(mini//1000000001)*1000000002)
			cont = True
			q = q + 1
			if q > Q-1:
				flag = True
				break
			d = int(inputs())
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			if mini == e[2]:
				cont = False
	for t in [None]*(Q-q):
		print(-1)
main()
### BUGGY CODE ###

import heapq

h,w = map(int,input().split())
sh,sw = map(int,input().split())
gh,gw = map(int,input().split())
s = [input() for _ in range(h)]

sh-=1; sw-=1; gh-=1; gw-=1;

INF = 10**7
dist = [[INF]*w for _ in range(h)]
dist[sh][sw] = 0
q = [(0,sh,sw)]

while q:
    
    d,vsh,vsw = heapq.heappop(q)
    
    for dh in range(-2,3):
        for dw in range(-2,3):
            newh = vsh+dh
            neww = vsw+dw
            if newh<0 or h<=newh or neww<0 or w<=neww: continue
            if dh == 0 and dw==0: continue
            if s[newh][neww] == "#": continue
                
            if abs(dh)+abs(dw)==1:
                if dist[newh][neww] > d:
                    dist[newh][neww] = d
                    heapq.heappush(q,(d,newh,neww))
            else:
                if dist[newh][neww] > d+1:
                    dist[newh][neww] = d+1
                    heapq.heappush(q,(d+1,newh,neww))
                    
if dist[gh][gw] == INF: print(-1)
else: print(dist[gh][gw])

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
sh,sw = map(int,input().split())
gh,gw = map(int,input().split())
s = [input() for _ in range(h)]

sh-=1; sw-=1; gh-=1; gw-=1;

dist = [[-1]*w for _ in range(h)]
dist[sh][sw] = 0
q = deque([(0,sh,sw)])
warpq = deque([])

while q or warpq:
    while q:

        d,vsh,vsw = q.popleft()

        flag = 0
        
        for dh,dw in [(-1,0),(1,0),(0,-1),(0,1)]:
            newh = vsh+dh
            neww = vsw+dw
            if newh<0 or h<=newh or neww<0 or w<=neww: continue
            if s[newh][neww] == "#":
                if flag ==0:
                    warpq.append((d,vsh,vsw))
                    flag = 1
                continue

            if dist[newh][neww] == -1:
                dist[newh][neww] = d
                q.append((d,newh,neww))

    while warpq:

        d,vsh,vsw = warpq.popleft()
        for dh in range(-2,3):
            for dw in range(-2,3):
                newh = vsh+dh
                neww = vsw+dw
                if newh<0 or h<=newh or neww<0 or w<=neww: continue
                if abs(dh)+abs(dw)<=0: continue
                if s[newh][neww] == "#": continue

                if dist[newh][neww] == -1:
                    dist[newh][neww] = d+1
                    q.append((d+1,newh,neww))
            
print(dist[gh][gw])
### BUGGY CODE ###

k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(s-x-y+1):
           if x+y+z==s and 0<=z<=k:
               ans += 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):
        z=s-x-y
        if x+y+z==s and 0<=z<=k:
            ans += 1
print(ans)
### BUGGY CODE ###

import sys
from collections import deque
finput=lambda: sys.stdin.readline().strip()

n=int(finput())
a=finput().split()
b=[]

for i in range(n):
  if (n-i)%2==0:
    b.append(a[i])
  else:
    b=[a[i]]+b
print(' '.join(b))


### FIXED CODE ###

import sys
from collections import deque
finput=lambda: sys.stdin.readline().strip()

n=int(finput())
a=finput().split()
b=deque()

for i in range(n):
  if (n-i)%2==0:
    b.append(a[i])
  else:
    b.appendleft(a[i])
print(' '.join(b))
### BUGGY CODE ###

n = int(input())
*A, = map(int, input().split())
a, b, c = A.count(1), A.count(2), A.count(3)
DP = [[[0 for k in range(n+1)] for j in range(n+1)] for i in range(n+1)]
for k in range(c+1):
    for j in range(b+c-k+1):
        for i in range(n-j-k+1):
            if i+j+k > 0:
                DP[i][j][k] += n/(i+j+k)
            if i > 0:
                DP[i][j][k] += DP[i-1][j][k]*i/(i+j+k)
            if j > 0:
                DP[i][j][k] += DP[i+1][j-1][k]*j/(i+j+k)
            if k > 0:
                DP[i][j][k] += DP[i][j+1][k-1]*k/(i+j+k)
print(DP[a][b][c])


### FIXED CODE ###

n = int(input())
*A, = map(int, input().split())
a, b, c = A.count(1), A.count(2), A.count(3)
DP = [[[0.0 for k in range(n+1)] for j in range(n+1)] for i in range(n+1)]
for k in range(c+1):
    for j in range(b+c-k+1):
        for i in range(n-j-k+1):
            if i+j+k == 0:
                continue
            tmp = n
            if i > 0:
                tmp += DP[i-1][j][k]*i
            if j > 0:
                tmp += DP[i+1][j-1][k]*j
            if k > 0:
                tmp += DP[i][j+1][k-1]*k
            DP[i][j][k] = tmp/(i+j+k)
print(DP[a][b][c])
### BUGGY CODE ###

s = input()
mod = 2019
ls = len(s)
cnt = 0
dp = []
for i in range(ls-3):
    st = int(s[i:i+2])
    if st%2!=0:
        continue
    for j in range(i+3,ls):
        c = int(s[i:j+1])
        if c in dp:
            cnt+=1
        elif c%mod ==0:
            dp.append(c)
            cnt+=1
print(cnt)

### FIXED CODE ###

s = input()
res = 0
m = 1
p =[0]*2019
for i in map(int,s[::-1]):
    res +=i*m
    res %=2019
    p[res] +=1
    m *=10
    m %=2019
print(p[0]+sum([i*(i-1)//2 for i in p]))
### BUGGY CODE ###

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

def cmb(n,k):
    if k>n:
        return 0
    elif k > (n+1)/2:
        return cmb(n,n-k)
    tmp = 1
    for i in range(n-k+1,n+1):
        tmp *= i
    for i in range(1,k+1):
        tmp //= i
    tmp %= mod
    return tmp    
        
    
mod = 10**9+7
for i in range(1,K+1):
    cr = cmb(N-K+1,i)
    cb = cmb(K-1,i-1)
    ans = cr*cb
    ans %= mod
    print(ans)
    

### FIXED CODE ###

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


mod = 10 ** 9 + 7
MAX = N+K
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod



def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
cominit()
'''
def cmb(n,k):
    if k>n:
        return 0
    elif k > (n+1)/2:
        return cmb(n,n-k)
    tmp = 1
    for i in range(n-k+1,n+1):
        tmp *= i
    for i in range(1,k+1):
        tmp //= i
    tmp %= mod
    return tmp    
'''        
    
for i in range(1,K+1):
    cr = cmb(N-K+1,i)
    cb = cmb(K-1,i-1)
    ans = cr*cb
    ans %= mod
    print(ans)
### BUGGY CODE ###

H, W = map(int, input().split())
maze = []
for i in range(H):
    maze.append(list(input()))
    
from collections import deque
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
# 最大の地点を
def dfs(sx, sy, gx, gy):
    que = deque()
    # 各点までの最長距離の配列
    d = [[-1 for _ in range(W)] for _ in range(H)]
    que.append([sx, sy])
    d[sx][sy] = 0
    
    while(len(que) != 0):
        front = que.popleft()
        if (front[0] == gx and front[1] == gy):
            break
        for i in range(4):
            nx = front[0] + dx[i]
            ny = front[1] + dy[i]
            if (0 <= nx and nx < H and 0 <= ny and ny < W):
                if maze[nx][ny] != "#" and d[nx][ny] == -1:
                    que.append([nx, ny])
                    d[nx][ny] = d[front[0]][front[1]] + 1
                else:
                    continue
            else:
                continue
    return d[gx][gy]

import itertools

ans = []
l1 = [(s1, s2) for s1 in range(H) for s2 in range(W)]
p = itertools.product(l1, l1)

for v in p:
    if v[0][0] == v[1][0] and v[0][1] == v[1][1]:
        continue
    if maze[v[0][0]][v[0][1]] == "#" or maze[v[1][0]][v[1][1]] == "#":
        continue
    ans.append(dfs(v[0][0], v[0][1], v[1][0], v[1][1]))
print(max(ans))

### FIXED CODE ###

H, W = map(int, input().split())
maze = []
for i in range(H):
    maze.append(list(input()))
    
from collections import deque
import numpy as np
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
# 最大の地点を
def dfs(sx, sy):
    que = deque()
    # 各点までの最長距離の配列
    d = [[-1 for _ in range(W)] for _ in range(H)]
    que.append([sx, sy])
    d[sx][sy] = 0
    
    while(len(que) != 0):
        front = que.popleft()
        for i in range(4):
            nx = front[0] + dx[i]
            ny = front[1] + dy[i]
            if (0 <= nx and nx < H and 0 <= ny and ny < W):
                if maze[nx][ny] != "#" and d[nx][ny] == -1:
                    que.append([nx, ny])
                    d[nx][ny] = d[front[0]][front[1]] + 1
                else:
                    continue
            else:
                continue
    return np.max(d)

import itertools

ans = []
l1 = [(s1, s2) for s1 in range(H) for s2 in range(W)]


for v in l1:
    if maze[v[0]][v[1]] == "#":
        continue
    ans.append(dfs(v[0], v[1]))
print(max(ans))
### BUGGY CODE ###

def main():
    n = int(input())
    h = list(map(int, input().split()))
    max = 0
    now = 0
    i = 0
    while i < n - 1:
        now = 0
        for j in range(i + 1, n):
            if h[j] <= h[j - 1]:
                now += 1
            else:
                i = j - 1
                break
        if now >= max:
            max = now
        i += 1
    print(max)

if __name__ == "__main__":
    main()



### FIXED CODE ###

def main():
    n = int(input())
    h = input().split()
    h = [int(n) for n in h]
    max = 0
    now = 0
    i = 0
    for i in range(n-1):
        if h[i] >= h[i+1]:
            now += 1
        else:
            if now >= max:
                max = now
            now=0
        if now >= max:
            max = now
    print(max)

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

n, k = [int(x) for x in input().split()]
a = [int(x)-1 for x in input().split()]

visited = [0]
order = {}
order[0] = 0
x = 0
T = -1
i = 0
while T<0:
  x = a[x]
  i+=1
  if x in visited:
    s = order[x]
    T = i - s
    break
  else:
    visited.append(x)
    order[x] = i
if k < s:
  print(visited[k]+1)
else:
  mod = (k-s) % T
  print(visited[s+mod]+1)


### FIXED CODE ###

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

visited = [-1 for i in range(n+1)] # 訪れていたら訪れたときの添字を格納する。
points = []
p = 1
while visited[p] == -1:
  visited[p] = len(points)
  points.append(p)
  p = a[p-1] #添字に直す

T = len(points) - visited[p]
s = visited[p]

if k < s:
  print(points[k])
else:
  mod = (k - s) % T
  print(points[s+mod])
### BUGGY CODE ###

from itertools import product
from operator import add

h, w = map(int, input().split())
rb = [['#'] * (w + 2)]
a = rb + [list('#' + input() + '#') for _ in range(h)] + rb
p = [(i, j) for i in range(1, h + 1) for j in range(1, w + 1) if a[i][j] == '#']
d = (-1, 0), (1, 0), (0, -1), (0, 1)
r = -1
while p:
    r += 1
    s = []
    for i, j in (map(add, x, y) for x, y in product(p, d)):
        if a[i][j] == '.':
            a[i][j] = '#'
            s.append((i, j))
    p = s
print(r)


### FIXED CODE ###

h, w = map(int, input().split())
a = [['#'] * (w + 2)] + [['#'] + list(input()) + ['#']
                          for _ in range(h)] + [['#'] * (w + 2)]
p = [(i, j) for i in range(1, h + 1) for j in range(1, w + 1) if a[i][j] == '#']
d = (-1, 0), (1, 0), (0, -1), (0, 1)
r = -1
while p:
    r += 1
    s = []
    for i, j in p:
        for di, dj in d:
            di += i
            dj += j
            if a[di][dj] == '.':
                a[di][dj] = '#'
                s.append((di, dj))
    p = s
print(r)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
v=[0]*64
ans=0
mod=1000000007
zero=0
one=0

index=n-1
while index>=0:
	for k in range(61):
		one=v[k]
		zero=n-1-index-one
		tmp=1<<k
		if((a[index]&tmp)==0):
			ans=(ans+tmp*one)%mod
		else:
			ans=(ans+tmp*zero)%mod
			v[k]=v[k]+1
	index-=1


print(ans)
print()

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
v=[0]*64
ans=0
mod=1000000007
zero=0
one=0

index=n-1
while index>=0:
	for k in range(61):
		one=v[k]
		zero=n-1-index-one
		tmp=1<<k
		if((a[index]&tmp)==0):
			ans=(ans+tmp*one)
		else:
			ans=(ans+tmp*zero)
			v[k]=v[k]+1
	index-=1

ans=ans%mod
print(ans)
print()
### BUGGY CODE ###

N, Q = map(int, input().split())
s = str(input())

t = []
d = []

for _ in range(Q):
    ti, di = map(str, input().split())
    t.append(ti)
    d.append(di)


def main_fanc(s, t, d, N):
    masu = {}
    for i, si in enumerate(s):
        if not si in masu:
            masu[si] = [i]
        else:
            masu[si].append(i)

    
    g = [1 for _ in range(N)]
    
    for ti, di in zip(t, d):
        if not ti in masu:
            continue
        if di == 'L':
            for pos in masu[ti]:
                if pos == 0:
                    g[pos] = 0
                else:
                    g[pos - 1] += g[pos]
                    g[pos] = 0
        if di == 'R':

            for pos in reversed(masu[ti]):
                if pos == N - 1:
                    g[pos] = 0
                else:
                    g[pos + 1] += g[pos]
                    g[pos] = 0
    
    print(sum(g))
                    

main_fanc(s, t, d, N)

### FIXED CODE ###

N, Q = map(int, input().split())
s = str(input())

t = []
d = []

for _ in range(Q):
    ti, di = input().split()
    t.append(ti)
    d.append(di)
    
LEFT_DIE = -1
RIGHT_DIE = N

def is_dead(i):
    for ti, di in zip(t, d):
        if s[i] == ti:
            if di == 'L':
                i -= 1
            if di == 'R':
                i += 1
            if i == LEFT_DIE:
                return LEFT_DIE
            if i == RIGHT_DIE:
                return RIGHT_DIE
    return 0

low = -1
high = N;
# LEFT
while high - low > 1:
    mid = (low + high) // 2;
    if is_dead(mid) == LEFT_DIE:
        low = mid
    else:
        high = mid
left_edge = high

low = -1
high = N;
# RIGHT
while high - low > 1:
    mid = (low + high) // 2;
    if is_dead(mid) == RIGHT_DIE:
        high = mid
    else:
        low = mid
right_edge = low

#print(left_edge, right_edge)
ans_s = s[left_edge:right_edge+1]
#print(ans_s)
ans = len(ans_s)
print(ans)
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    start = time.time()
    n,m = LI()
    a = [LI() for _ in range(m)]
    e = [set() for _ in range(n)]
    for l,r,d in a:
        e[l-1].add((r-1,d))
        e[r-1].add((l-1,-d))

    b = [False] * n
    def g(i,c):
        gt = time.time() - start
        if gt > 1.9:
            return True
        if c == False:
            c = 0
        b[i] = c
        for r,d in e[i]:
            if b[r] != False:
                if b[r] != c+d:
                    return False
            else:
                if not g(r,c+d):
                    return False
        return True

    for i in range(n):
        if b[i] != False:
            continue
        if not g(i,False):
            return 'No'
    return 'Yes'


print(main())





### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    e = [[] for _ in range(n)]
    if m > 0:
        for _ in range(m):
            l,r,d = LI()
            e[l-1].append((r-1,d))
            e[r-1].append((l-1,-d))

    b = [None] * n

    for i in range(n):
        if not b[i] is None:
            continue
        b[i] = 0
        q = [i]
        qi = 0
        nq = []
        while True:
            if len(q) == qi:
                if not nq:
                    break
                q = nq
                qi = 0
                nq = []
            j = q[qi]
            qi += 1
            c = b[j]
            for r,d in e[j]:
                if b[r] is None:
                    b[r] = c+d
                    nq.append(r)
                else:
                    if b[r] != c+d:
                        return 'No'

    return 'Yes'


print(main())
### BUGGY CODE ###

# 2019-11-19 01:10:02(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    s = list(itertools.accumulate(a))

    count = s.count(0)
    for i in range(n-1):
        for j in range(i+1, n):
            if s[j] - s[i] == 0:
                count += 1

    print(count)

if __name__ == "__main__":
    main()


### FIXED CODE ###

# 2019-11-19 01:10:02(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
from scipy.misc import comb # (default: exact=False)
# import numpy as np

# def nCr(n, r):
#     r = min(n, r)
#     return np.cumprod(range(n, n-r, -1)) // np.cumprod(range(r, 0, -1))

def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    s = list(itertools.accumulate(a))

    
    res = s.count(0)
    for x in [x for x in collections.Counter(s).values() if x >= 2]:
        res += comb(x, 2, exact=True)

    print(res)

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

import sys
input=sys.stdin.readline
n=int(input())
lists=list(map(int,input().split()))
aa=[0 for i in range(n)]
length=61
use=[0 for i in range(61)]
for  j in range(n):
    k=format(lists[j],"0%ib"%length)
    k=k[::-1]
    aa[j]=k  
for p in aa:    
    for some in range(61):
        use[some]+=int(p[some])

answer=0

for j in range(61):
    answer+=(2**j)*use[j]*(n-use[j])%(10**9+7)
print(answer%(10**9+7))

### FIXED CODE ###

n=int(input())
lists=list(map(int,input().split()))
length=61
use=[0 for i in range(61)]
a,b=divmod(n,9)
anslist=[0 for i in range(a+1)]
for  j in range(n):
    k=format(lists[j],"0%ib"%length)
    k=k[::-1]
    p,q=divmod(j,9)
    if p>a:
        anslist.append(str(k))
    else:
        anslist[p]+=int(k)
answer=0
for some in anslist:
    some=str(some)
    some=some.zfill(61)
    for j in range(61):
        if int(some[j])!=0:
            use[j]+=int(some[j])

for j in range(61):
    answer+=(2**j)*use[j]*(n-use[j])%(10**9+7)
print(answer%(10**9+7))