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

import numpy as np

D = int(input())
Cs = list(map(int, input().split()))
Ss = []
for d in range(D):
    s = list(map(int, input().split()))
    Ss.append(s)

Ss = np.array(Ss)

solution = np.argmax(Ss, axis=1)

days_till_next = np.ones_like(Ss) * (D - 1) - np.arange(D).reshape((D, 1))


def update_days_till_next(d, erase=False):
    contest = solution[d]
    delta = days_till_next[d + 1, contest] + 1 if d < D - 1 else 0
    days_till_next[d, contest] = delta
    for _d in range(d - 1, -1, -1):
        if solution[_d] == contest or _d == 0:
            days_till_next[_d:d, contest] = (d - _d + 1) - np.arange(d - _d) + (delta if erase else 0)
            break


def update_days_till_next_old(d):
    contest = solution[d]
    if d < D - 1:
        days_till_next[d, contest] = days_till_next[d + 1, contest] + 1
    for _d in range(d - 1, -1, -1):
        if solution[_d] == contest or _d == 0:
            days_till_next[_d:d, contest] = (d - _d + 1) - np.arange(d - _d)
            break

for d in range(D - 1, -1, -1):
    update_days_till_next(d)

for _ in range(1000):
    n_contests = len(Ss[0])
    days_since_last = np.zeros(n_contests)
    for d, i in enumerate(solution):
        days_since_last += 1
        new_scores = days_till_next[d] * days_since_last * Cs + Ss[d]
        new_i = new_scores.argmax()
        days_since_last[new_i] = 0
        if new_i != i:
            update_days_till_next(d, erase=True)
            solution[d] = new_i
            update_days_till_next(d)


for s in solution:
    print(s + 1)

with open("test.out", "w") as f:
    f.writelines("\n".join(list(map(str, solution + 1))))


### FIXED CODE ###

import numpy as np

D = int(input())
Cs = list(map(int, input().split()))
Ss = []
for d in range(D):
    s = list(map(int, input().split()))
    Ss.append(s)

Ss = np.array(Ss)

solution = np.argmax(Ss, axis=1)
#
# days_till_next = np.ones_like(Ss) * (D - 1) - np.arange(D).reshape((D, 1))
#
#
# def update_days_till_next(d):
#     contest = solution[d]
#     for _d in range(d - 1, -1, -1):
#         if solution[_d] == contest or _d == 0:
#             days_till_next[_d:d, contest] -= days_till_next[d, contest]
#             break
#
#
# for d in range(D - 1, -1, -1):
#     update_days_till_next(d)
#
# for _ in range(10):
#     n_contests = len(Ss[0])
#     days_since_last = np.zeros(n_contests)
#     for d, i in enumerate(solution):
#         days_since_last += 1
#         new_scores = days_till_next[d] * days_since_last[d] * Cs + Ss[d]
#         new_i = new_scores.argmax()
#         days_since_last[new_i] = 0
#         if new_i != i:
#             solution[d] = new_i
#             update_days_till_next(d)
#

for s in solution:
    print(s + 1)
### BUGGY CODE ###

import sys
from collections import deque

input = sys.stdin.readline


def bfs(H, W, A, dist):
    queue = deque([])
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                dist[h][w] = 0
                queue.append((h, w))
    while queue:
        h, w = queue.popleft()
        for y, x in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            next_h, next_w = h + y, w + x
            if not (0 <= next_h < H and 0 <= next_w < W):
                continue
            if dist[next_h][next_w] == -1:
                dist[next_h][next_w] = dist[h][w] + 1
                queue.append((next_h, next_w))


def main():
    H, W = map(int, input().split())
    A = [None] * H
    for i in range(H):
        A[i] = input().rstrip()

    dist = [[-1] * W for _ in range(H)]
    bfs(H, W, A, dist)

    ans = max(map(max, dist))
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import deque

input = sys.stdin.readline


def bfs(H, W, A, dist):
    queue = deque([])
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                dist[h][w] = 0
                queue.append((h, w))
    while queue:
        h, w = queue.popleft()
        for y, x in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            next_h, next_w = h + y, w + x
            if dist[next_h][next_w] == -1:
                dist[next_h][next_w] = dist[h][w] + 1
                queue.append((next_h, next_w))


def main():
    H, W = map(int, input().split())
    A = [None] * (H + 2)
    A[0] = A[-1] = "." * (W + 2)
    for i in range(1, H + 1):
        A[i] = "".join([".", input().rstrip(), "."])

    dist = [[0] + [-1] * W + [0] for _ in range(H + 2)]
    dist[0] = dist[-1] = [0] * (W + 2)
    bfs(H + 2, W + 2, A, dist)

    ans = max(map(max, dist))
    print(ans)


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

import functools
import operator

N = int(input())

L = list(range(1, N+1, 1))
prod = functools.partial(functools.reduce, operator.mul)

print(prod(L)%(10**9+7))


### FIXED CODE ###

N = int(input())
calc = 1
for i in range(1, N+1):
    calc = (i*calc) % (10**9+7)

print(calc)
### BUGGY CODE ###

N = int(input())
S = input()

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A

ans = 0
for i in range(N):
    z = z_algo(S[i:])
    z = z[(len(z)+1)//2:]
    if z:
        max_z = max(z)
        ans = max(ans, max_z)
print(ans)

### FIXED CODE ###

def resolve():
    import sys
    input=sys.stdin.readline
    N = int(input().rstrip())
    S = input().rstrip()

    def z_algo(s):
        """
        param s:str
        return list of int with length len(s)
        """
        # initialization
        n=len(s)
        z=[0]*n
        z[0]=n
        # construct
        L,R=0,0
        for i in range(1,n):
            if i>R: # 過去の結果が全く使えない
                L=R=i
                while(R<n and s[R-L]==s[R]): R+=1
                z[i]=R-L
                R-=1 # 0-indexedでiと比較するため
            elif z[i-L]<R-i+1:
                z[i]=z[i-L]
            else:
                L=i
                R+=1 # Rまでは確定しているので、R+1から確認
                while(R<n and s[R-L]==s[R]): R+=1
                z[i]=R-L
                R-=1
        return z

    ans = 0
    for i in range(N-1):
        z = z_algo(S[i:])
        for j, _z in enumerate(z):
            ans=max(ans,min(j,z[j]))
    print(ans)

resolve()
### BUGGY CODE ###

from sys import stdin

def main():
    point = 0
    r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
    for i in range(n//r+1):
        for j in range(n//g+1):
            if n-r*i-g*j >= 0:
                if (n-r*i-g*j)%b == 0:
                    point += 1
    print(point)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from sys import stdin
import math

point = 0

r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(n//r+1):
    for j in range(n//g+1):
        if n-r*i-g*j >= 0:
            if (n-r*i-g*j)%b == 0:
                point += 1

print(point)
### BUGGY CODE ###

n,W=map(int,input().split())
items=[list(map(int,input().split())) for i in range(n)]
w=[items[i][0] for i in range(n)]
v=[items[i][1] for i in range(n)]

dp=[[0]*(W+1) for i in range(n+1)]
for i in range(n-1,-1,-1):
  for j in range(W+1):
    if j<w[i]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i])

print(dp[0][W])
    
    

### FIXED CODE ###

import sys
input=sys.stdin.readline

n,W=map(int,input().split())
items=[list(map(int,input().split())) for i in range(n)]
import numpy as np

dp=np.zeros([n+1,W+1],dtype=np.int64)
for i in range(n):
  w=items[i][0]
  v=items[i][1]
  dp[i+1][:w]=dp[i][:w]
  dp[i+1][w:]=np.maximum(dp[i][w:],dp[i][:-w]+v)
print(dp[-1][-1])
### BUGGY CODE ###

def main():
  h,w,k=map(int,input().split())
  p=[[0]*w for _ in range(h)]
  for _ in range(k):
    r,c,v=map(int,input().split())
    p[r-1][c-1]=v
  dp=[[[0]*4 for j in range(w)] for i in range(h)]
  if p[0][0]!=0:
    dp[0][0][1]=p[0][0]
  for y in range(h):
    for x in range(w):
      for i in range(4):
        if x<w-1:
          if dp[y][x+1][i]<dp[y][x][i]:
            dp[y][x+1][i]=dp[y][x][i]
          if i<3 and p[y][x+1]!=0 and dp[y][x+1][i+1]<dp[y][x][i]+p[y][x+1]:
            dp[y][x+1][i+1]=dp[y][x][i]+p[y][x+1]
        if y<h-1:
          if dp[y+1][x][0]<dp[y][x][i]:
            dp[y+1][x][0]=dp[y][x][i]
          if p[y+1][x]!=0 and dp[y+1][x][1]<dp[y][x][i]+p[y+1][x]:
            dp[y+1][x][1]=dp[y][x][i]+p[y+1][x]
  print(max(dp[h-1][w-1]))
main()

### FIXED CODE ###

def main():
  import sys
  input=sys.stdin.readline
  h,w,k=map(int,input().split())
  H=range(h)
  W=range(w)
  dp=[[[0]*w for j in H] for i in range(4)]
  for _ in range(k):
    r,c,v=map(int,input().split())
    dp[0][r-1][c-1]=v
  if dp[0][0][0]!=0:
    dp[1][0][0]=dp[0][0][0]
    dp[0][0][0]=0
  for y in H:
    for x in W:
      v=dp[0][y][x]
      dp[0][y][x]=0
      for i in range(4):
        if 0<x:
          if dp[i][y][x]<dp[i][y][x-1]:
            dp[i][y][x]=dp[i][y][x-1]
          if 0<i and v!=0 and dp[i][y][x]<dp[i-1][y][x-1]+v:
            dp[i][y][x]=dp[i-1][y][x-1]+v
        if 0<y:
          if dp[0][y][x]<dp[i][y-1][x]:
            dp[0][y][x]=dp[i][y-1][x]
          if v!=0 and dp[1][y][x]<dp[i][y-1][x]+v:
            dp[1][y][x]=dp[i][y-1][x]+v
  print(max([dp[i][h-1][w-1] for i in range(4)]))
main()
### BUGGY CODE ###

def solve():
  N, W = map(int, input().split())
  weight = [0 for i in range(N)]
  value = [0 for i in range(N)]
  for i in range(N):
    weight[i], value[i] = map(int, input().split())
  dp = [[0 for w in range(100100)] for i in range(110)]

  for i in range(N):
    for w in range(W + 1):
      if w - weight[i] >= 0:
        dp[i + 1][w] = max(dp[i + 1][w], dp[i][w - weight[i]] + value[i])
      dp[i + 1][w] = max(dp[i + 1][w], dp[i][w])

  return dp[N][W]

print(solve())


### FIXED CODE ###

def solve():
    N, W = map(int, input().split())
    weight = [0 for i in range(N)]
    value = [0 for i in range(N)]
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    dp = [0 for w in range(W + 1)]

    for i in range(N):
        wi = weight[i]
        vi = value[i]
        for w in range(W, -1, -1):
            _w = w + wi
            _v = dp[w] + vi
            if _w > W: continue
            if _v <= dp[_w]: continue
            dp[_w] = _v
    return dp[-1]

print(solve())
### BUGGY CODE ###

# 長さNの文字列Sについて、i=2,3,...,N でのSのi文字目以降から成る文字列とSの最長共通接頭辞の長さ O(N) 
def z_algo(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = 0
    c = 0 #最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        #i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP
  
N = int(input())
S = input()

ans = 0
for i in range(N):
  SS = S[i:]
  lcp = z_algo(SS)
  for j in range(len(lcp)):
    l = min(lcp[j], j)
    ans = max(ans, l)

print(ans)

### FIXED CODE ###

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

l = 0
r = 1
ans = 0
# 順番に見ていく

while r < n:
  if s[l:r] in s[r:]:
    ans = max(ans, r - l)
    r += 1
  else:
    l += 1
  if l == r:
    l += 1
    r += 2
print(ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(1,n+1):
  for j in range(n):
    if i==a[j]:
      b.append(j+1)
      break
print(*b)

### FIXED CODE ###

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

import math

A, B = list(map(int, input().split()))
x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  x = max(x_minA, x_minB)
  while (x * 8 / 100 - A >= 1) or (x / 10 - B >= 1):
    print(x, x * 8 / 100, x / 10)
    x += 1
  
  print(x)

### FIXED CODE ###

import math
 
A, B = list(map(int, input().split()))
x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  for x in range(max(x_minA, x_minB), min(x_maxA, x_maxB)+1):
    if int(x * 8 / 100) == A and int(x / 10)==B:
      print(x)
      break
  else:
    print(-1)
### BUGGY CODE ###

# C
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(n-1):
    for j in range(i+1, n):
        ans += (a[i]*a[j])
print(int(ans % mod))


### FIXED CODE ###

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

# 累積和ベクトルbを作成
a.reverse()
b = [0]*n
b[0] = a[0]
for i in range(1, n):
    b[i] = b[i-1]+a[i]
a.reverse()
b.reverse()

ans = 0
for i in range(n-1):
    ans += a[i]*b[i+1]

print(ans % (10**9+7))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def line_to_int(): return int(sys.stdin.readline())
def line_to_each_int(): return map(int, sys.stdin.readline().split())
def line_to_list(): return list(map(int, sys.stdin.readline().split()))
def line_to_list_in_iteration(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
# def dp(init, i, j): return [[init]*i for i2 in range(j)]
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
# from itertools import accumulate #A = [0]+list(accumulate(A))
# import bisect #bisect.bisect_left(B, a), bisect.bisect_right(B,a)

n = line_to_int()
a = line_to_list()
ans = a[0]

for i in range(1,n):
    ans = ans * a[i]

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

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def line_to_int(): return int(sys.stdin.readline())
def line_to_each_int(): return map(int, sys.stdin.readline().split())
def line_to_list(): return list(map(int, sys.stdin.readline().split()))
def line_to_list_in_iteration(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
# def dp(init, i, j): return [[init]*i for i2 in range(j)]
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
# from itertools import accumulate #A = [0]+list(accumulate(A))
# import bisect #bisect.bisect_left(B, a), bisect.bisect_right(B,a)

n = line_to_int()
a = line_to_list()

# from functools import reduce, partial
# from operator import mul

# prod = partial(reduce, mul)

# if 0 in a:
#     print(0)
# else:
#     if prod(a) <= 10**18:
#         print(prod(a))
#     else:
#         print(-1)
ans = a[0]
limit = 10**18
if 0 in a:
    print(0)
else:
    for i in range(1,n):
        if ans <= limit:
            ans = ans * a[i]
        else:
            print(-1)
            exit()
    if ans <= limit:
        print(ans)
    else:
        print(-1)
### BUGGY CODE ###

N = int(input())
count = 0
clip = []
for i in range(N):
    S = input()
    if S not in clip:
        
        clip.append(S)
        count = count + 1
    
print(count)

### FIXED CODE ###

N = int(input())

clip = set()
for i in range(N):
    S = input()
    clip.add(S)

    
print(len(clip))
### BUGGY CODE ###

# ABC138D - Ki
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, tree, cnt):
    for u in tree[v]:
        if u != p:
            cnt[u] += cnt[v]
            dfs(u, v, tree, cnt)


def main():
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # T[i] := children of vertex i
    cnt = [0] * (N + 1)
    for a, b in A:  # set tree relations
        T[a] += [b]
        T[b] += [a]
    for p, x in P:  # increment on roots
        cnt[p] += x
    dfs(1, -1, T, cnt)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC138D - Ki
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, tree, cnt):
    for u in tree[v]:
        if u != p:
            cnt[u] += cnt[v]
            dfs(u, v, tree, cnt)


def main():
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # T[i] := children of vertex i
    cnt = [0] * (N + 1)
    for a, b in A:  # set tree relations
        T[a] += [b]
        T[b] += [a]
    for p, x in P:  # increment on roots
        cnt[p] += x
    dfs(1, -1, T, cnt)
    print(*cnt[1:])


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

n = int(input())
P = list(map(int, input().split(' ')))

count = 1
for i in range(1, n):
    if min(P[:i+1]) == P[i]:
        count += 1
print(count)


### FIXED CODE ###

n = int(input())
P = list(map(int, input().split(' ')))

count = 0
minimum = 2 * 10 ** 5 + 1
for p in P:
    if p < minimum:
        count += 1
        minimum = p
print(count)
### BUGGY CODE ###

range = xrange
input = raw_input
MOD = 10**9+7
 
n = int(input())
 
dp = [0] * (1 << n)
for i in [i for i, x in enumerate(input().split()) if x == '1']:
    dp[1 << i] = 1
 
npow = 1 << n
 
for i in range(n - 1):
    _dp = [0] * npow
    for j in [i for i, x in enumerate(input().split()) if x == '1']:
        jpow = 1 << j
        mask = (npow - 1) ^ jpow
        x = npow
        while x:
            x = (x-1)&mask
            _dp[x + jpow] += dp[x]
    for mask in range(npow):
        _dp[mask] %= MOD
    dp = _dp
 
print(sum(dp) % MOD)

### FIXED CODE ###

range = xrange
input = raw_input
MOD = 10**9+7
 
n = int(input())

dp = [0] * (1 << n)
for i in [i for i, x in enumerate(input().split()) if x == '1']:
    dp[1 << i] = 1

npow = 1 << n

for i in range(n - 1):
    _dp = [0] * npow
    for j in [i for i, x in enumerate(input().split()) if x == '1']:
        jpow = 1 << j
        mask = 0
        while mask < npow:
            _dp[mask + jpow] += dp[mask]
            mask += 1 + ((mask+1) & jpow)
    for mask in range(npow):
        _dp[mask] %= MOD
    dp = _dp
 
print(sum(dp) % MOD)
### BUGGY CODE ###

n = int(input())

t_num , a_num = map(int, input().split())

for t, a in [map(int, input().split()) for _ in range(n-1)]:
    pre_t_num, pre_a_num = t_num, a_num
    t_num, a_num = t, a
    n = 1
    while t_num < pre_t_num or a_num < pre_a_num:
        n = n + 1
        t_num, a_num = t * n, a * n

ans = t_num + a_num
print(ans)


### FIXED CODE ###

n = int(input())

t_num , a_num = 1, 1

for t, a in [map(int, input().split()) for _ in range(n)]:
    pre_t_num, pre_a_num = t_num, a_num
    t_num, a_num = t, a
    if t_num < pre_t_num or a_num < pre_a_num:
        # m = m + 1
        t_k = (pre_t_num + t - 1) // t
        a_k = (pre_a_num + a - 1) // a
        m = max(t_k, a_k)
        t_num, a_num = t * m, a * m

ans = t_num + a_num
print()
print(ans)
### BUGGY CODE ###

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

graph = [
    [ False for _ in range(n) ]
    for _ in range(n)
]

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

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

count = 0

for j, link in enumerate(graph):
    if not any(link):
        count += 1

    else:
        linked_hi = [ hi[i] for i, connected in enumerate(link) if connected ]

        if all(map(lambda x: hi[j] > x, linked_hi)):
            count += 1

print(count)

### FIXED CODE ###

n, m = [ int(x) for x in input().split() ]
hs   = [ int(x) for x in input().split() ] # len(hs) == n

vs = [ [] for _ in range(n) ]

for i in range(m):
    s, g = input().split()

    s = int(s) - 1
    g = int(g) - 1

    vs[s].append(g)
    vs[g].append(s)

goods = []

for i, v in enumerate(vs):
    if len(v) == 0:
        goods.append(i + 1)

    if all(hs[i] > hs[d] for d in v):
        goods.append(i + 1)

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

A,B,K = map(int,input().split())
for i in range(A,B+1):
    if i < A+K or B-K < i: print(i)

### FIXED CODE ###

A,B,K = map(int,input().split())
if 2*K<B-A+1:
    S = [i for i in range(A,A+K)]+[i for i in range(B-K+1,B+1)]
else:
    S = [i for i in range(A,B+1)]
for s in S:
    print(s)
### BUGGY CODE ###

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

def f(i):
    total = 0
    for j in range(N):
        total += A[(i + j) % N] * (1 if j % 2 == 0 else -1)
    return total

B = [f(i) for i in range(N)]

print(' '.join(map(str, B)))

### FIXED CODE ###

from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))

@lru_cache(maxsize=N)
def f(i):
    if i >= 2:
        return f(i - 2) + 2 * A[i - 1] - 2 * A[i - 2]
    total = 0
    for j in range(N):
        if j % 2 == 0:
            total += A[(i + j) % N]
        else:
            total -= A[(i + j) % N]
    return total

B = (f(i) for i in range(N))

print(*B)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    mod = 7 + 10**9
    leng = len(format(max(a), 'b'))
    bit_acc = [0 for i in range(leng)]
    for i in range(n):
        # 先頭から二進数を0埋めした
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                bit_acc[j] += 1
    ans = 0
    for i in range(n):
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                ans += (n - bit_acc[j]) * (2 ** (leng - j - 1))
            else:
                ans += bit_acc[j] * (2 ** (leng - j - 1))
            ans %= mod
    print((ans * 500000004) % mod)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    mod = 7 + 10**9
    leng = len(format(max(a), 'b'))
    bit_acc = [0 for i in range(leng)]
    for i in range(n):
        # 先頭から二進数を0埋めした
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                bit_acc[j] += 1
    p = [pow(2, (leng - j - 1), mod) for j in range(leng)]
    ans = 0
    for i in range(n):
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                ans += (n - bit_acc[j]) * p[j]
            else:
                ans += bit_acc[j] * p[j]
            ans %= mod
    print((ans * 500000004) % mod)


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

N=int(input())
l=list(map(int,input().split()))
l.sort()

cnt=0
for i in range(N-1):
    for j in range(i+1,N):
        k=j+1
        while k<N:
            if l[i]+l[j]>l[k]:
                cnt+=1
                k+=1
            else:
                cnt+=0
                k+=1
print(cnt)


### FIXED CODE ###

import bisect
N=int(input())
l=list(map(int,input().split()))
l.sort()

cnt=0
for i in range(N-1):
    for j in range(i+1,N):
        ind = bisect.bisect_left(l,l[i]+l[j])
        cnt += ind - j-1

        # k=j+1
        # while k<N:
        #     if l[i]+l[j]>l[k]:
        #         cnt+=1
        #         k+=1
        #     else:
        #         cnt+=0
        #         k+=1
print(cnt)