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

N = int(input())
A = []

S = [0] * (N+1)
for i in range(N):
    A.append(int(input()))
    S[i+1] = S[i] + A[i]

for i in range(N):
    MAX = -float('inf')
    for j in range(N):
        if j == i:
            continue
        else:
            MAX = max(MAX, S[j+1] - S[j])
    print(MAX)

### FIXED CODE ###

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

MAX_1 = max(A)
MAX_2 = sorted(A)[-2]

for i in range(N):
    if A[i] == MAX_1:
        print(MAX_2)
    else:
        print(MAX_1)
### BUGGY CODE ###

n=int(input())
a=list(input().split())
b=''
if n%2==0:
  for i in range(n):
    if i%2==0:
      b+=a[i]+' '
    else:
      b=a[i]+' '+b
else:
  for i in range(n):
    if i%2!=0:
      b+=a[i]+' '
    else:
      b=a[i]+' '+b
      
print(b[:-1])

### FIXED CODE ###

n=int(input())
a=list(input().split())
if n%2==0:
  b=a[-1::-2]+a[0::2]
else:
  b=a[-1::-2]+a[1::2]
ans=''
for i in range(n):
  ans+=b[i]+' '
print(ans[:-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from fractions import gcd

def GCD_LCM(A:list, N:int):
    GCD = A[0]
    LCM = A[0]
    for i in range(1,N):
        if GCD != 1:
            GCD = gcd(GCD,A[i])
        LCM = (LCM * A[i]) // gcd(LCM, A[i])
    return GCD,LCM

def main():
    N = int(input())
    A = sorted([int(i) for i in input().split()])
    MOD = 10**9+7

    GCD, LCM = GCD_LCM(A,N)
    ans = 0
    MAXA = A[-1]
    if GCD != 1 and LCM == MAXA:
        for i in A:
            ans = (ans + MAXA // i) % MOD
    else:
        for i in A:
            ans = (ans + LCM // i) % MOD

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
from fractions import gcd
from functools import reduce

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]
# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def gcd_list(numbers):
    return reduce(gcd, numbers)
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = sorted([int(i) for i in input().split()])
    MOD = 10**9+7

    GCD = gcd_list(A)
    LCM = lcm_list(A) % MOD
    ans = 0
    if GCD != 1 and LCM == A[-1]:
        for i in range(N):
            ans = (ans + A[-1] * mod_inv(A[i],MOD)) % MOD
    else:
        for i in range(N):
            ans = (ans + LCM * mod_inv(A[i],MOD)) % MOD

    print(ans)

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

def knapsack_1(N, W, lst):
    #N : 品物数
    #W : 重みの総和
    #lst (wi,vi) : 商品iの重みwi、価値vi
    
    #dp[i][j] : i番目の品物から重さの総和がj以下になるように選んだ場合の価値の総和の最大値
    dp = [[0 for i in range(W+1)] for _ in range(N+1)]
    
    for i in range(N):
        for j in range(W+1):
            if j < lst[i][0]:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = max(dp[i][j],dp[i][j - lst[i][0]] + lst[i][1])
    return dp[N][W]


n,w = map(int,input().split())
lst = []
for i in range(n):
    w_, v_ =  map(int,input().split())
    lst.append((w_, v_))
print(knapsack_1(n,w,lst))

### FIXED CODE ###

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

lstw, lstv = [], []
for i in range(n):
    w_,v_ = map(int,input().split())
    lstw.append(w_)
    lstv.append(v_)

dp = [[0 for i in range(w+1)] for _ in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j < lstw[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-lstw[i]]+lstv[i])
print(dp[n][w])
### BUGGY CODE ###

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

ans = 0
for i in range(N):
    # print(P[:i+1])
    m = min(P[:i+1])
    if P[i] <= m:
        # print(i)
        ans += 1
    # m = max(P[:i+1])
    # print(m)


print(ans)


### FIXED CODE ###

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

m = P[0]
ans = 0
for i in range(N):
    # print(P[:i+1])
    if P[i] <= m:
        m = P[i]
        # print(i)
        ans += 1
    # m = max(P[:i+1])
    # print(m)


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

Ncount = int(input())
strings = []
count_flag = 0
letters_count = []
for i in range(Ncount):
  strings.append(input())
  
def letter_count(string):
  letters = {}
  for i in range(10):
    if string[i] not in letters:
      letters[string[i]] = 1
    else :
      letters[string[i]] += 1
  return letters

for i in strings:
  letters_count.append(letter_count(i))


for i in range(len(letters_count)):
  for j in range(i+1, len(letters_count)):
    if letters_count[i] == letters_count[j]:
      count_flag += 1

print(count_flag)

### FIXED CODE ###

Ncount = input()
strings = []
count_flag = 0
letters = {}
for i in range(int(Ncount)):
  strings.append(''.join(sorted(input())))

for i in strings:
  if i not in letters:
    letters[i] = 0
  else :
    letters[i] += 1
    count_flag += letters[i]

print(count_flag)
### BUGGY CODE ###

from itertools import combinations

def get_d_min(a, b, X, Y):

    d = abs(a - b)
    if a == X and b == Y:
        d = 1
    elif a <= X and b > X and b <= Y:
        dd = (X - a) + (Y - b) + 1
        d = min(d, dd)
    elif a >= X and a < Y and b >= Y:
        dd = (a - X) + (b - Y) + 1
        d = min(d, dd)
    elif a > X and b < Y:
        dd = (a - X) + (Y - b) + 1
        d = min(d, dd)
    elif a < X and b > Y:
        dd = (X - a) + (b - Y) + 1
        d = min(d, dd)
    return d

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

comb = combinations(range(1, N + 1), 2)

counts = [0] * N
for a, b in comb:
    a, b = min(a, b), max(a, b)
    d_min = get_d_min(a, b, X, Y)
    counts[d_min] += 1

for count in counts[1:]:
    print(count)

### FIXED CODE ###

from itertools import combinations

def get_d_min(a, b, X, Y):

    d = abs(a - b)
    if a == X and b == Y:
        d = 1
    elif a <= X and b > X and b <= Y:
        dd = (X - a) + (Y - b) + 1
        d = min(d, dd)
    elif a >= X and a < Y and b >= Y:
        dd = (a - X) + (b - Y) + 1
        d = min(d, dd)
    elif a > X and b < Y:
        dd = (a - X) + (Y - b) + 1
        d = min(d, dd)
    elif a < X and b > Y:
        dd = (X - a) + (b - Y) + 1
        d = min(d, dd)
    return d

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

comb = combinations(range(1, N + 1), 2)

counts = [0] * N
for a, b in comb:
    a, b = min(a, b), max(a, b)
    d_min = get_d_min(a, b, X, Y)
    counts[d_min] += 1

for count in counts[1:]:
    print(count)
### BUGGY CODE ###

d = [int(x) for x in input().split()]
count = 0
for y in range(d[0], d[1] + 1):
  if y % d[2] != 0 and y % d[3] != 0:
    count += 1
   
print(count)

### FIXED CODE ###

import fractions

d = [int(x) for x in input().split()]
lcm = int(d[2] * d[3] // fractions.gcd(d[2], d[3]))
b = d[1] - int(d[1] // d[2]) - int(d[1] // d[3]) + int(d[1] // lcm)
a_1 = d[0] - 1
a = a_1 - int(a_1 // d[2]) - int(a_1 // d[3]) + int(a_1 // lcm)
print(b - a)
### BUGGY CODE ###

from collections import deque

H, W, K = map(int,input().split())
x1,y1,x2,y2 = map(int,input().split())
c = list(list(input())for _ in range(H))
cost = [[H*W+1]*W for _ in range(H)]
cost[x1-1][y1-1] = 0
queue = deque([[x1-1,y1-1]])
while queue:
    x,y = queue.popleft()
    for vecx,vecy in [[0,1],[1,0],[-1,0],[0,-1]]:
        for k in range(1,K+1):
            nx,ny = x+k*vecx, y+k*vecy
            if not(0<=nx<H) or not(0<=ny<W):
                break
            if c[nx][ny] == '@':
                break
            if cost[nx][ny] > cost[x][y]+1:
                cost[nx][ny] = cost[x][y]+1
                queue.append([nx,ny])
            elif cost[nx][ny] < cost[x][y]:
                break
if cost[x2-1][y2-1] == H*W+1:
    print(-1)
else:
    print(cost[x2-1][y2-1])




### FIXED CODE ###

from collections import deque

H, W, K = map(int,input().split())
x1,y1,x2,y2 = map(int,input().split())
c = list(list(input())for _ in range(H))
cost = [[H*W+1]*W for _ in range(H)]
cost[x1-1][y1-1] = 0
queue = deque([[x1-1,y1-1]])
while queue:
    x,y = queue.popleft()
    for vecx,vecy in [[0,1],[1,0],[-1,0],[0,-1]]:
        for k in range(1,K+1):
            nx,ny = x+k*vecx, y+k*vecy
            if not(0<=nx<H) or not(0<=ny<W):
                break
            if c[nx][ny] == '@':
                break
            if cost[nx][ny] > cost[x][y]+1:
                cost[nx][ny] = cost[x][y]+1
                queue.append([nx,ny])
            elif cost[nx][ny] < cost[x][y]+1:
                break
if cost[x2-1][y2-1] == H*W+1:
    print(-1)
else:
    print(cost[x2-1][y2-1])
### BUGGY CODE ###

n, k = [ int(v) for v in input().split() ]
coordinate_list = sorted([ int(v) for v in input().split() ]) 

def fire(inlist):
    if inlist[0] * inlist[-1] >= 0:
        r = max(abs(inlist[0]),abs(inlist[-1]))
    else:
        r = abs(inlist[0]) + abs(inlist[-1]) + min(abs(inlist[0]),abs(inlist[-1]))
    return r

ans = 10**14
for i in range(n-k+1):
    
    ans = min(fire(coordinate_list[i:i+k]),ans)
print(ans)

### FIXED CODE ###

n, k = [ int(v) for v in input().split() ]
coordinate_list = sorted([ int(v) for v in input().split() ]) 

def fire(a,b):
    if a * b >= 0:
        r = max(abs(a),abs(b))
    else:
        r = abs(a) + abs(b) + min(abs(a),abs(b))
    return r

ans = 10**14
for i in range(n-k+1):
    ans = min(fire(coordinate_list[i],coordinate_list[i+k-1]),ans)
print(ans)
### BUGGY CODE ###

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

# 隣接リストを作成
adjacencyList = [[] for _ in range(N)]

# 距離の情報
dp = [0] * N

# 入次数　（いりじすう）
deg = [0] * N

for _ in range(M):
    v, nv = map(int, input().split())
    adjacencyList[v-1].append(nv-1)
    #　入次数に1を足す
    deg[nv-1] += 1
    
queue = []

# BFS探索
# 入次数がゼロの頂点から探索を始める
for v in range(N):
    if deg[v] == 0:
        queue.append(v)

while queue:
    # 現在の頂点をqueueからpop
    v = queue.pop(0)
    for nv in adjacencyList[v]:
        # 探索済みの頂点の入次数を減らす
        deg[nv] -= 1
        
        # 完全に探索済みの頂点の入次数がゼロの時、経路の距離を出発点から計算
        if deg[nv] == 0:
            # 頂点をqueueに追加する
            queue.append(nv)
            dp[nv] = max(dp[v] + 1, dp[nv])
            
print(max(dp))

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**9)

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

g = [[] for i in range(n+1)]

dp = [-1] * (n+1)
for _ in range(m):
    v1 , v2 = map(int,input().split())
    g[v1].append(v2)
    
# finding longest path for vertice i
def dfs(i):
    if dp[i]!=-1:
        return dp[i]
    temp = 0
    for nv in g[i]:
        temp = max(temp, dfs(nv)+1)

    dp[i]=temp
    return temp
  
# finding overall longest path  
res = 0  
for i in range(1,n+1):
    res = max(res, dfs(i))
print(res)
### BUGGY CODE ###

from collections import deque

def main():
  H,W,K=map(int,input().split())
  x1,y1,x2,y2 = map(lambda x: int(x)-1,input().split())
  S=[list(input()) for _ in range(H)]

  def bfs(x0,y0,x_goal,y_goal):
    seen = [[0 for i in range(W)] for j in range(H)]
    d = [[0 for i in range(W)] for j in range(H)]
    todo = deque()
    if S[x0][y0]=='@':return 0
    seen[x0][y0] = 1
    todo.append((x0,y0))
    while todo:
      x0,y0 = todo.popleft()
      dx,dy = (1,-1,0,0),(0,0,1,-1)
      for i in range(4):
        for k in range(K):
          x,y = x0+dx[i]*(k+1), y0+dy[i]*(k+1)
          if x<0 or x>=H:break
          if y<0 or y>=W:break
          if seen[x][y]==1:continue
          if S[x][y]=='@':break
          seen[x][y] = 1
          todo.append((x,y))
          d[x][y] = d[x0][y0] + 1
          if x==x_goal and y == y_goal: return d[x][y]
    return d[x_goal][y_goal]

  ans = bfs(x1,y1,x2,y2)
  print(ans if ans > 0 else -1)
  
if __name__ == "__main__":
  main()

### FIXED CODE ###

from collections import deque

def main():
  H,W,K=map(int,input().split())
  x1,y1,x2,y2 = map(lambda x: int(x)-1,input().split())
  S=[list(input()) for _ in range(H)]
  INF = 10**20

  def bfs(x0,y0,x_goal,y_goal):
    seen = [[0 for i in range(W)] for j in range(H)]
    d = [[INF for i in range(W)] for j in range(H)]
    d[x0][y0] = 0
    todo = deque()
    seen[x0][y0] = 1
    todo.append((x0,y0))
    while todo:
      x0,y0 = todo.popleft()
      dx,dy = (1,-1,0,0),(0,0,1,-1)
      for i in range(4):
        for k in range(K):
          x,y = x0+dx[i]*(k+1), y0+dy[i]*(k+1)
          if x<0 or x>=H:break
          if y<0 or y>=W:break
          if d[x][y] < d[x0][y0] + 1: break
          if S[x][y]=='@':break
          if seen[x][y]: continue
          seen[x][y] = 1
          todo.append((x,y))
          d[x][y] = d[x0][y0] + 1
          if x==x_goal and y == y_goal: return d[x][y]
    return d[x_goal][y_goal]

  ans = bfs(x1,y1,x2,y2)
  print(ans if ans < INF else -1)
  
if __name__ == "__main__":
  main()
### BUGGY CODE ###

s = input()

q = int(input())

for i in range(q):
    li = list(map(str, input().split()))
    if li[0] == "2":
        if li[1] =="1":
            s = li[2] + s

        elif li[1] == "2":
            s = s + li[2]

    elif li[0] == "1":
        s = s[::-1]

print(s)





### FIXED CODE ###


s = input()

q = int(input())
x = []
y = []

flag = 0

for i in range(q):
    li = list(input().split())
    if flag%2 == 0:
        if li[0] == "2":
            if li[1] =="1":
                x.append(li[2])
            else:
                y.append(li[2])
        else:
            flag += 1

    else:
        if li[0] == "2":
            if li[1] =="1":
                y.append(li[2])
            else:
                x.append(li[2])
        else:
            flag += 1

if flag%2 == 0:
    x = x[::-1]
    print("".join(x)+s+"".join(y))

else:
    s = s[::-1]
    y = y[::-1]
    print("".join(y)+s+"".join(x))
### BUGGY CODE ###

import queue

h, w = map(int, input().split(" "))

s = list()
for l in range(0, h):
    line = input()
    s.append(line)

dx = {(1, 0), (-1, 0), (0, 1), (0, -1)}


def search(start_h, start_w):
    if s[start_h][start_w] == "#":
        return -1

    cost = [[10000000 for i in range(0, w)] for j in range(0, h)]

    q = queue.Queue()
    q.put((start_h, start_w, 0))
    cost[start_h][start_w] = 0
    while not q.empty():
        current_h, current_w, current_c = q.get()

        # print("pos_w:%d, pos_h:%d, cost:%d" % (current_w, current_h, current_c))
        for dw, dh in dx:
            next_h = current_h + dh
            next_w = current_w + dw
            next_c = current_c + 1

            if next_h < 0 or next_h >= h or next_w < 0 or next_w >= w:
                continue

            if s[next_h][next_w] == "#" or cost[next_h][next_w] < next_c:
                continue
            else:
                q.put((next_h, next_w, next_c))
                cost[next_h][next_w] = next_c

    tmp = 0
    for a in range(0, w):
        for b in range(0, h):
            if cost[b][a] > 1000:
                continue
            else:
                tmp = max(tmp, cost[b][a])

    return tmp


ans = 0
for i in range(0, w):
    for j in range(0, h):
        # print("start_h:%d, start_w:%d" % (j, i))
        cost_tmp = search(j, i)
        ans = max(ans, cost_tmp)
        # print("start_h:%d, start_w:%d cost:%d" % (j, i, cost_tmp))


print(ans)


### FIXED CODE ###

import queue

h, w = map(int, input().split(" "))

s = list()
for l in range(0, h):
    line = input()
    s.append(line)

dx = {(1, 0), (-1, 0), (0, 1), (0, -1)}


def search(start_h, start_w):
    if s[start_h][start_w] == "#":
        return -1

    cost = [[10000000 for i in range(0, w)] for j in range(0, h)]

    q = queue.Queue()
    q.put((start_h, start_w, 0))
    cost[start_h][start_w] = 0
    while not q.empty():
        current_h, current_w, current_c = q.get()
        # print("(%d, %d, %d)" % (current_h, current_w, current_c))

        # print("pos_w:%d, pos_h:%d, cost:%d" % (current_w, current_h, current_c))
        for dw, dh in dx:
            next_h = current_h + dh
            next_w = current_w + dw
            next_c = current_c + 1

            if next_h < 0 or next_h >= h or next_w < 0 or next_w >= w:
                continue

            if s[next_h][next_w] == "#" or cost[next_h][next_w] <= next_c:
                continue
            else:
                q.put((next_h, next_w, next_c))
                cost[next_h][next_w] = next_c

    tmp = 0
    for a in range(0, w):
        for b in range(0, h):
            if cost[b][a] > 1000:
                continue
            else:
                tmp = max(tmp, cost[b][a])

    return tmp


ans = 0
for i in range(0, w):
    for j in range(0, h):
        # print("start_h:%d, start_w:%d" % (j, i))
        cost_tmp = search(j, i)
        ans = max(ans, cost_tmp)
        # print("start_h:%d, start_w:%d cost:%d" % (j, i, cost_tmp))


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

X=int(input())
prime=[2]
for i in range(3,10**5+10**4):
  for k in prime:
    if i%k==0:
      break
    if k==prime[-1]:
      prime+=[i]
for i in prime:
  if i>=X:
    ans=i
    break
print(ans)    

### FIXED CODE ###

X=int(input())
prime=[2]
for i in range(3,10**5+10**4):
  for k in prime:
    if i%k==0:
      break
    if k==prime[-1]:
      prime+=[i]
for i in prime:
  if i>=X:
    ans=i
    break
print(ans)
### BUGGY CODE ###

import math


def resolve():
    A, B, N = map(int, input().split())

    ans = 0

    for i in range(N, 1, -1):
        tmp = math.floor(A * i / B) - A * math.floor(i / B)
        ans = max(tmp, ans)

    print(ans)


resolve()

### FIXED CODE ###

def resolve():
    A, B, N = map(int, input().split())
    print(A * min(N, B - 1) // B)


resolve()
### BUGGY CODE ###

S = input()
S_len = len(S)
while True:
    if "01"in S:
        S =S.replace("01","",1)
    elif "10" in S:
        S =S.replace("10","",1)
    else:
        break
print(S_len - len(S))

### FIXED CODE ###

S = list(input())
zero_num = S.count("0")
one_num = S.count("1")
print(len(S)-abs(zero_num - one_num))
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
  return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(a,b,c)
print(ans)

### FIXED CODE ###

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

k = int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(gcd(a,b),c)
print(ans)
### BUGGY CODE ###

N = int(input())

ans = 0
for i in range(N):
    ans = ans + i

print(ans)

### FIXED CODE ###

N = int(input())

ans = N * (N - 1) // 2

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

h,w,m=map(int, input().split())
r = [0]*max(h,w)
c = [0]*max(h,w)
l=[]

for i in range(m):
    x,y=map(int, input().split())
    r[x-1]+=1
    c[y-1]+=1
    l.append([x,y])

cm = max(c)
rm = max(r)
ci = [i for i, x in enumerate(c) if x == cm]
ri = [i for i, x in enumerate(r) if x == rm]
ans = cm + rm

cnt = 0
#print(l,ci,ri)
for i in range(m):
    if l[i][0]-1 in ri and l[i][1]-1 in ci:
        cnt += 1

if cnt == len(ci)*len(ri):
    print(int(ans)-1)
else:
    print(int(ans))

### FIXED CODE ###

h,w,m=map(int, input().split())
r = [0]*max(h,w)
c = [0]*max(h,w)
l=[]

for i in range(m):
    x,y=map(int, input().split())
    r[x-1]+=1
    c[y-1]+=1
    l.append([x,y])

cm = max(c)
rm = max(r)
ci = [i for i, x in enumerate(c) if x == cm]
ri = [i for i, x in enumerate(r) if x == rm]
ans = cm + rm

cnt = 0
#print(l,ci,ri)
for i in range(m):
    if r[l[i][0]-1] == rm and c[l[i][1]-1] ==cm:
        cnt += 1

if cnt == len(ci)*len(ri):
    print(int(ans)-1)
else:
    print(int(ans))
### BUGGY CODE ###

h,w,d=map(int,input().split())
a=[ [ [] for j in range(int(h*w/d+1)) ] for i in range(d) ]

for i in range(h):
  i+=1
  tmp=list(map(int,input().split()))
  for j in range(w):
    num=tmp[j]
    j+=1
    a[num%d][int( (num-1)/d)]=[i,j]

q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  ans=0
  x=-1
  y=-1
  for j in a[l%d][int((l-1)/d):int((r-1)/d)+1]:
    if x==-1:
      x,y=j[0],j[1]
    else:
      ans+=abs(x-j[0])+abs(y-j[1])
      x,y=j[0],j[1]
  print(ans)

### FIXED CODE ###

h,w,d=map(int,input().split())
a=[ [ [] for j in range(int(h*w/d+1)) ] for i in range(d) ]
a1=[ [ [] for j in range(int(h*w/d+1)) ] for i in range(d) ]
for i in range(h):
  i+=1
  tmp=list(map(int,input().split()))
  for j in range(w):
    num=tmp[j]
    j+=1
    a[num%d][int( (num-1)/d)]=[i,j]
for i in range(len(a)):
  a1[i][0]=0
  for j in range(len(a[i])-1):
    j=j+1
    if a[i][j]!=[]:
      a1[i][j]=a1[i][j-1]+abs(a[i][j][0]-a[i][j-1][0])+abs(a[i][j][1]-a[i][j-1][1])

q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  print(a1[l%d][int((r-1)/d)]-a1[l%d][int((l-1)/d)])
### BUGGY CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()

ans = 0
for i in range(60):
    s = 0
    t = 0
    for x in a:
        if ( x // 2**i ) % 2 == 0:
            s += 1
        else:
            t += 1
    ans = ( ans + s * t * 2**i ) % ( 10**9 + 7 )
print(ans)

### FIXED CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()

ans = 0
k = 1
for i in range(60):
    s = 0
    t = 0
    for j in range(n):
        if a[j] % 2 == 0:
            s += 1
        else:
            t += 1
        a[j] //= 2
    ans = ( ans + s * t * k ) % ( 10**9 + 7 )
    k *= 2
print(ans)
### BUGGY CODE ###

a = int(input())
b = []
for i in range(len(str(a))):
    b.append(str(a)[i])
b = [int(j) for j in b]
if sum(b) % 9 == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a = str(input())
b = []
c = 0
for i in range(len(a)):
    b.append(int(a[i]))
if sum(b) % 9 == 0:
    print("Yes")
else:
    print("No")