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

# ac
import numpy as np
# imos法
def update(a):
    n = len(a)
    b = np.zeros_like(a)       # aと同じ形状の配列を生成(https://deepage.net/features/numpy-zeros.html)
    for i, x in enumerate(a):  # enumerateはindex, valueを返す
        l = max(0, i - x)      # lampの照らす範囲の下限（左側）
        r = min(n - 1, i + x)  # lampの上限（右側）
        b[l] += 1              # 以下imos法
        if r + 1 < n:          # r+1はx=nの時（最後のサイクル）r+1=nでindexの指定に失敗するから弾く（indexは0~n-1）
            b[r + 1] -= 1
    b = np.cumsum(b)           # bの要素の累積和（フィボナッチ数列みたいな）（imos法の締め）
    return b

n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))

k = min(k, 41)                 # 今回の制限範囲のnなら41回も試行すればaの値が全て上限に達するのでそれ以上の試行は不要（解説PDF）
for _ in range(k):
    a = update(a)
print(' '.join(map(str, a)))   # joinメソッドはstrを''で区切って連結する

### FIXED CODE ###

# ac
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i8[::1],)', cache=True)
def update(a):
    n = len(a)
    b = np.zeros_like(a)       # aと同じ形状の配列を生成(https://deepage.net/features/numpy-zeros.html)
    for i, x in enumerate(a):  # enumerateはindex, valueを返す
        l = max(0, i - x)      # lampの照らす範囲の下限（左側）
        r = min(n - 1, i + x)  # lampの上限（右側）
        b[l] += 1              # 以下imos法
        if r + 1 < n:          # r+1はx=nの時（最後のサイクル）r+1=nでindexの指定に失敗するから弾く（indexは0~n-1）
            b[r + 1] -= 1
    b = np.cumsum(b)           # bの要素の累積和（フィボナッチ数列みたいな）（imos法の締め）
    return b


n, k = map(int, readline().split())
a = np.array(read().split(), np.int64)

k = min(k, 41)                 # 今回の制限範囲のnなら41回も試行すればaの値が全て上限に達するのでそれ以上の試行は不要（解説PDF）
for _ in range(k):
    a = update(a)
print(' '.join(map(str, a)))   # joinメソッドはstrを''で区切って連結する
### BUGGY CODE ###

from itertools import product


def solve(n, a_list, b_list):

    res = 10 ** 9 + 7

    for p in product([0, 1], repeat=n):
        if sum(p) % 2 == 1:
            continue

        r = 0

        c_list = [a for a in a_list]
        for i in range(n):
            if p[i] == 1:
                c_list[i] = b_list[i]
        c_list_s = list(sorted(c_list))

        used = [0] * n
        d_list = [0] * n
        for k in range(n):
            j = -1
            for i in range(n):
                if c_list[i] == c_list_s[k] and not used[i] and (i - k + p[i]) % 2 == 0:
                    used[i] = 1
                    j = i
                    break
            if j >= 0:
                d_list[j] = k
            else:
                r += 10 ** 9 + 7

        # r
        for i in range(n - 1):
            for j in range(i + 1, n):
                if d_list[i] > d_list[j]:
                    r += 1

        res = min(res, r)
    # print(res)
    if res < 10 ** 9 + 7:
        return res
    else:
        return -1


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    res = solve(n, a_list, b_list)
    print(res)


def test():
    assert solve(3, [3, 4, 3], [3, 2, 3]) == 1
    assert solve(2, [2, 1], [1, 2]) == -1
    assert solve(4, [1, 2, 3, 4], [5, 6, 7, 8]) == 0


if __name__ == "__main__":
    test()
    main()


### FIXED CODE ###

from itertools import product


def solve(n, a_list, b_list):

    res = 10 ** 9 + 7

    for p in product([0, 1], repeat=n):
        if sum(p) % 2 == 1:
            continue

        r = 0

        c_list = [a for a in a_list]
        for i in range(n):
            if p[i] == 1:
                c_list[i] = b_list[i]
        c_list_s = list(sorted(c_list))

        used = [0] * n
        d_list = [0] * n
        for k in range(n):
            j = -1
            for i in range(n):
                if c_list[i] == c_list_s[k] and not used[i] and (i - k + p[i]) % 2 == 0:
                    used[i] = 1
                    j = i
                    break
            if j >= 0:
                d_list[j] = k
            else:
                r += 10 ** 9 + 7

        # r
        for i in range(n - 1):
            for j in range(i + 1, n):
                if d_list[i] > d_list[j]:
                    r += 1

        res = min(res, r)
    # print(res)
    if res < 10 ** 9 + 7:
        return res
    else:
        return -1


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    res = solve(n, a_list, b_list)
    print(res)


def test():
    assert solve(3, [3, 4, 3], [3, 2, 3]) == 1
    assert solve(2, [2, 1], [1, 2]) == -1
    assert solve(4, [1, 2, 3, 4], [5, 6, 7, 8]) == 0


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

def Warshall_Floyd(edges,N):
  """頂点N個のグラフ上の隣接行列edges(空欄はinfとせよ)が与えられたとき, 
  2点間の最短距離距離を隣接行列で返す"""
  for k in range(N):
    for i in range(min(100,N)):
      for j in range(i):
        if edges[i][j]>edges[i][k]+edges[k][j]: return 1
  return 0
 
import sys
from sys import stdin
input = stdin.readline
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
if Warshall_Floyd(A,N):
  print(-1)
  sys.exit()
 
ans=0
for i in range(N):
  for j in range(i):
    need=1
    for k in range(N):
      if k!=i and k!=j and A[i][j]==A[i][k]+A[k][j]:
        need=0
        break
    if need:ans+=A[i][j]
print(ans)

### FIXED CODE ###

def Warshall_Floyd(edges,N):
  """頂点N個のグラフ上の隣接行列edges(空欄はinfとせよ)が与えられたとき, 
  2点間の最短距離距離を隣接行列で返す"""
  for k, i, j in itertools.product(range(N), range(N),range(N)):
    if edges[i][j]>edges[i][k]+edges[k][j]: return 1
  return 0
 
import sys
import itertools
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
if Warshall_Floyd(A,N):
  print(-1)
  sys.exit()
 
ans=0
for i, j in itertools.product(range(N),range(N)):
  need=1
  for k in range(N):
    if k!=i and k!=j and A[i][j]==A[i][k]+A[k][j]:
      need=0
      break
  if need:ans+=A[i][j]
print(ans//2)
### BUGGY CODE ###

def sgm(i):
    sum=0
    for j in range(i+1):
        sum+=j
    return sum

n, k=map(int, input().split())
p=list(map(int, input().split()))
idx=0
sum=0
for i in range(k):
    sum+=p[i]
max=sum
for i in range(k,n):
    sum+=p[i]
    sum-=p[i-k]
    if sum>=max:
        max=sum
        idx=i-k+1

e=0
for i in range(idx,idx+k):
    e+=(sgm(p[i])/p[i])
print(e)

### FIXED CODE ###

n, k=map(int, input().split())
p=list(map(int, input().split()))
idx=0
sum=0
for i in range(k):
    sum+=p[i]
max=sum
for i in range(k,n):
    sum+=p[i]
    sum-=p[i-k]
    if sum>=max:
        max=sum
        idx=i-k+1

e=0
for i in range(idx,idx+k):
    e+=((p[i]+1)/2)
print(e)
### BUGGY CODE ###

N, M = map(int, input().split())
B = [list(map(int, input().split())) for _ in range(M)]

pt = []
G = [[0, 1] for x in range(N+1)]

def find(x):
    while G[x][0] != 0:
        x = G[x][0]
    return x

cnt = 0
while len(B):
    x, y = B.pop()
    wx = find(x)
    wy = find(y)
    if wx == wy:
        pt.append(0)
    else:
        pt.append(G[wx][1] * G[wy][1])
        G[wx][1] += G[wy][1]
        G[wy][0] = wx

    #print(G)

cnt = 0
while len(pt):
    cnt += pt.pop()
    print(cnt)


### FIXED CODE ###

N, M = map(int, input().split())
B = [list(map(int, input().split())) for _ in range(M)]

pt = []
G = [[None, 1] for x in range(N+1)]

def find(x):
    n = G[x]
    c = []
    while not n[0] is None:
        c.append(n)
        n = n[0]
    for ci in c:
        ci[0] = n
    return n

cnt = 0
while len(B):
    x, y = B.pop()
    wx = find(x)
    wy = find(y)
    if wx is wy:
        pt.append(0)
    else:
        pt.append(wx[1] * wy[1])
        wx[1] += wy[1]
        wy[0] = wx

    #print(G)

cnt = 0
for _ in range(M):
    cnt += pt.pop()
    print(cnt)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, P = MAP()
S = input()

if P == 2 or P == 5:
	ans = 0

	for i, s in enumerate(S):
		if int(s)%P == 0:
			ans += i+1
	print(ans)

else:
	tmp = ""

	mod_dic = defaultdict(int)

	for i, s in enumerate(S[::-1]):
		tmp = s + tmp
		mod_dic[int(tmp)%P] += 1
	ans = 0
	for v in mod_dic.values():
		ans += v*(v-1)//2
	print(ans+mod_dic[0])


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	N, P = MAP()
	S = list(map(int, list(input())))

	if P == 2 or P == 5:
		ans = 0

		for i, s in enumerate(S):
			if int(s)%P == 0:
				ans += i+1
		print(ans)

	else:
		tmp = 0

		mod_cnt = [0]*P

		z = 1
		for i, n in enumerate(S[::-1]):
			tmp += n*z
			z = z * 10 % P
			mod_cnt[int(tmp)%P] += 1
		ans = 0
		for v in mod_cnt:
			ans += v*(v-1)//2
		print(ans+mod_cnt[0])


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

import numpy as np
n = (int)(input())
s = []
t = []
for _ in range(n):
    a, b = (list)(map(int, input().split()))
    s.append(a)
    t.append(b)
mi = min(s)
ma = max(t)


def primeList(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2, N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


def prime(s, t):
    primes = primeList(t)
    l = [0]*(t+1)
    c = 0
    s = 0
    for i in range(s, t+1):
        if i in primes and (i+1)//2 in primes:
            c += 1
        l[i] = c
    return l


primes = prime(mi, ma)
for i in range(n):
    print(primes[t[i]] - primes[s[i]-1])


### FIXED CODE ###

from itertools import accumulate

N = 100000
prime = [True]*(N+1)

prime[0] = prime[1] = False

for i in range(N+1):
    if prime[i]:
        for j in range(2*i, N+1, i):
            prime[j] = False

prime2 = [0] * (N+1)

for i in range(N+1):
    if prime[i] and prime[(i+1)//2]:
        prime2[i] = 1

acc = list(accumulate(prime2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(acc[r]-acc[l-1])
### BUGGY CODE ###

a=int(input())
b=list(map(int,input().split()))
cc=1
c=0
d=[0 for i in range(a)]
while cc<a:
  c+=b[cc]*2
  cc+=2
d[0]=sum(b)-c
e=str(d[0])
for i in range(1,a):
  d[i]=b[i-1]*2-d[i-1]
  e=e+" "+str(d[i])

print(e)

### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
cc=1
d=[0 for i in range(a)]
d[0]=sum(b[0::2])-sum(b[1::2])
print(str(d[0]), end="")
for i in range(1,a):
  d[i]=b[i-1]*2-d[i-1]
  print(" "+str(d[i]), end="")
### BUGGY CODE ###

import sys
from collections import deque

s = list(sys.stdin.readline().rstrip())
q = int(sys.stdin.readline())
querys = [sys.stdin.readline().split() for _ in range(q)]
s = deque(s)

for query in querys:
    if len(query) == 1:
        s.reverse()
    else:
        if query[1] == '1':
            s.appendleft(query[2])
        else:
            s.append(query[2])

print(''.join(s))


### FIXED CODE ###

import sys
from collections import deque

s = list(sys.stdin.readline().rstrip())
q = int(sys.stdin.readline())
head = 0
s = deque(s)

for _ in range(q):
    query = sys.stdin.readline().split()
    if len(query) == 1:
        head = 1 if head == 0 else 0
    elif (query[1] == '1' and head == 1) or (query[1] == '2' and head == 0):
        s.append(query[2])
    else:
        s.appendleft(query[2])

if head == 1:
    s.reverse()

print(''.join(s))
### BUGGY CODE ###

def main():
  import sys
  input=sys.stdin.readline
  h,w,k=map(int,input().split())
  sx,sy,tx,ty=map(int,input().split())
  sx-=1
  sy-=1
  tx-=1
  ty-=1
  calc=lambda x,y:x*1000000+y
  b=[]
  for i in range(h):
    s=input()
    bb=[]
    for j in s:
      if j==".":bb.append(0)
      else:bb.append(-1)
    b.append(bb)
  from collections import deque
  d=deque()
  d.append(calc(sx,sy))
  s=set()
  while d:
    x,y=divmod(d.popleft(),1000000)
    if calc(x,y)in s:
      s.discard(calc(x,y))
      continue
    if x==tx and y==ty:
      exit(print(b[x][y]))
    for i in range(1,k+1):
      if x-i<0:break
      if b[x-i][y]<=b[x][y] and b[x-i][y]!=0:break
      d.append(calc(x-i,y))
      if b[x-i][y]!=0:
        s.add(calc(x-i,y))
      b[x-i][y]=b[x][y]+1
    for i in range(1,k+1):
      if x+i==h:break
      if b[x+i][y]<=b[x][y] and b[x+i][y]!=0:break
      d.append(calc(x+i,y))
      if b[x+i][y]!=0:
        s.add(calc(x+i,y))
      b[x+i][y]=b[x][y]+1
    for j in range(1,k+1):
      if y-j<0:break
      if b[x][y-j]<=b[x][y] and b[x][y-j]!=0:break
      d.append(calc(x,y-j))
      if b[x][y-j]!=0:
        s.add(calc(x,y-j))
      b[x][y-j]=b[x][y]+1
    for j in range(1,k+1):
      if y+j==w:break
      if b[x][y+j]<=b[x][y] and b[x][y+j]!=0:break
      d.append(calc(x,y+j))
      if b[x][y+j]!=0:
        s.add(calc(x,y+j))
      b[x][y+j]=b[x][y]+1
  print(-1)
if __name__ == "__main__":
  main()

### FIXED CODE ###

import sys
input=sys.stdin.readline
h,w,k=map(int,input().split())
si,sj,ti,tj=map(int,input().split())
si-=1
sj-=1
ti-=1
tj-=1
b=[input()for _ in range(h)]
ans=[[-1]*w for _ in range(h)]
ans[si][sj]=0
from collections import deque
d=deque()
d.append((si,sj))
while d:
  x,y=d.popleft()
  if x==ti and y==tj:
    exit(print(ans[x][y]))
  for dx,dy in [[1,0],[-1,0],[0,-1],[0,1]]:
    for i in range(1,k+1):
      xx=x+dx*i
      yy=y+dy*i
      if not(0<=xx<h and 0<=yy<w) or b[xx][yy]=="@":break
      if 0<=ans[xx][yy]<=ans[x][y]:break
      if ans[xx][yy]==-1:d.append((xx,yy))
      ans[xx][yy]=ans[x][y]+1
print(-1)
### BUGGY CODE ###

# 最後のr,g,bでDP

from collections import defaultdict
from itertools import permutations

MOD = 1000000007

iist = lambda: map(int,input().split())
N,M = iist()
Q = list(tuple(iist()) for i in range(M))
dp = defaultdict(int)
dp[(0,0)] = 1

for pk in range(N):
  k = pk+1
  ndp = defaultdict(int)

  for (i,j),cnt in dp.items():
    cnt %= MOD
    ndp[(i,j)] += cnt 
    ndp[(i,pk)] += cnt
    ndp[(j,pk)] += cnt
  dp = ndp


  subQ = [(l,x) for l,r,x in Q if r==k]

  for (i,j) in list(dp.keys()):
    for (l,x) in subQ:
      if x != (l <= i) + (l <= j) + 1:
        del dp[(i,j)]
        break


print(sum(dp.values())%MOD)

### FIXED CODE ###

from collections import defaultdict

MOD = 1000000007
iist = lambda: map(int,input().split())

N,M = iist()
Q = defaultdict(list)
for i in range(M):
  l,r,x = iist()
  Q[r].append((l,x))

if any(x != 1 for l,x in Q[1]):
  print(0)
  exit(0)

dp = defaultdict(int)
dp[0,0] = 3

x_sum = [3]
y_sum = [3]
s = 3

for pk in range(1,N):
  k = pk+1

  for i,(a,b) in enumerate(zip(x_sum,y_sum)):
    c = (a+b)%MOD
    dp[i,pk] = c
    x_sum[i] += c

  x_sum.append(0)
  y_sum.append((2*s)%MOD)
  s *= 3
  subQ = Q[k]

  for i,j in list(dp.keys()):
    for l,x in subQ:
      if x != (l<=i)+(l<=j)+1:
        c = dp[i,j]
        x_sum[i] -= c
        y_sum[j] -= c
        s -= c
        del dp[i,j]
        break

  for i in range(pk):
    x_sum[i] %= MOD
    y_sum[i] %= MOD
  s %= MOD

print(s)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [input() for _ in range(N)]

dic = defaultdict(int)

for x in S:
	dic[x] += 1

ma = max(dic.values())

max_k_list = sorted([kv[0] for kv in dic.items() if kv[1] == max(dic.values())])

for i in max_k_list:
	print(i)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [input() for _ in range(N)]

dic = defaultdict(int)

for x in S:
	dic[x] += 1

ma = max(dic.values())

a = []
for i in dic.items():
	if i[1] == ma:
		a.append(i[0])

a = sorted(a)
for i in a:
	print(i)
### BUGGY CODE ###

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

x = list(map(int,input().split()))
y = list(map(int,input().split()))

sum = 0
for i in range(n-1):
  for j in range(m-1):
    h = x[i+1] - x[i]
    v = y[j+1] - y[j]
    sum += h*v*(i+1)*(n-i-1)*(j+1)*(m-j-1)

mod = 10 ** 9 + 7
print(sum % mod)

### FIXED CODE ###

mod = 10 ** 9 + 7

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

x = list(map(int,input().split()))
y = list(map(int,input().split()))

sum_h = 0
sum_v = 0
for i in range(n-1):
  sum_h += (x[i+1] - x[i])*(i+1)*(n-i-1)
sum_h = sum_h % mod

for j in range(m-1):
  sum_v += (y[j+1] - y[j])*(j+1)*(m-j-1)
sum_v = sum_v % mod

sum = (sum_h * sum_v) % mod

#print(sum_h,sum_v)
print(sum)
### BUGGY CODE ###

H = int(input())

count = 0
while True:
    count += 1
    H = H // 2
    if H == 1:
        break

L = 2 ** (count + 1) - 1

print(L)

### FIXED CODE ###

H = int(input())
import numpy as np
from math import ceil

L = int(np.log2(H))
K = ceil(np.log2(H))
if K == L:
    count = K
else:
    count = K - 1
L = 2 ** (count + 1) - 1

print(L)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import heapq

n,m,s,t = map(int, input().split())
s -= 1
t -= 1
ea = [set() for _ in range(n)]
eb = [set() for _ in range(n)]
for _ in range(m):
    v,u,a,b = map(int, input().split())
    v -= 1
    u -= 1
    ea[v].add((u,a))
    ea[u].add((v,a))
    eb[v].add((u,b))
    eb[u].add((v,b))


def dijkstra(e,n,s):
    d = [None]*n
    d[s] = 0
    q = [(s,0)]
    heapq.heapify(q)

    while len(q)>0:
        v,c = heapq.heappop(q)
        if d[v] is not None and d[v]<c:
            continue
        for u,ud in e[v]:
            if d[u] is None or d[u]>c+ud:
                d[u] = c + ud
                heapq.heappush(q, (u, d[u]))
    return d


da = dijkstra(ea,n,s)
db = dijkstra(eb,n,t)
res = []
m = None
for i in range(n-1,-1,-1):
    r = da[i]+db[i]
    if m is None:
        m = r
    else:
        m = min(m,r)

    res.append(m)

for i in range(n-1,-1,-1):
    print(10**15 - res[i])

### FIXED CODE ###

# -*- coding: utf-8 -*-
import heapq
n,m,s,t = map(int, input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    u,v,a,b = map(int, input().split())
    g[u].append((v,(a,b)))
    g[v].append((u,(a,b)))

inf = 10**18
def dijkstra(s, currency):
    d = [inf]*(n+1)
    d[s] = 0

    que = [(d[s],s)]
    heapq.heapify([que])
    while len(que)>0:
        _,v = heapq.heappop(que)
        for u,c in g[v]:
            if d[v]+c[currency]>=d[u]:
                continue
            d[u] = d[v]+c[currency]
            heapq.heappush(que, (d[u], u))
    return d

yen_c = dijkstra(s,0)
snuuk_c = dijkstra(t,1)

res = [0]*n
res[n-1] = yen_c[n] + snuuk_c[n]
for i in range(n-2,-1,-1):
    res[i] = min(res[i+1], yen_c[i+1]+snuuk_c[i+1])

for r in res:
    print(10**15-r)
### BUGGY CODE ###

n = int(input())
al = list(map(int, input().split()))
ans = []
for i in range(1, n+1):
    print(al.index(i) + 1)

### FIXED CODE ###

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

r1, c1, r2, c2 = map(int, input().split())
MOD = 10**9+7

def init_mod_c(lim=10**6*2, mod=10**9+7):
    fact = [1, 1] + [0] * (lim-1)
    fact_inv = [1, 1] + [0] * (lim-1)
    inv = [0, 1] + [0] * (lim-1)
    
    for i in range(2, lim+1):
        fact[i] = fact[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod

    def mod_c(n, m):
        if n < m or n < 0 or m < 0: return 0
        return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod

    return mod_c

comb = init_mod_c()
pc = lambda r, c: comb(r+c, min(r, c))

ans = 0
for i in range(r1, r2+1):
    ans += pc(i+1, c2)
    if c1 > 0: ans -= pc(i+1, c1-1)
    ans %= MOD

print(ans)


### FIXED CODE ###

r1, c1, r2, c2 = map(int, input().split())
MOD = 10**9+7

def init_mod_c(lim=10**7, mod=10**9+7):
    fact = [1, 1] + [0] * (lim-1)
    fact_inv = [1, 1] + [0] * (lim-1)
    inv = [0, 1] + [0] * (lim-1)
    
    for i in range(2, lim+1):
        fact[i] = fact[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod

    def mod_c(n, m):
        if n < m or n < 0 or m < 0: return 0
        return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod

    return mod_c

comb = init_mod_c()
pc = lambda r, c: comb(r+c, min(r, c))

ans = 0
for i in range(r1, r2+1):
    ans += pc(i+1, c2)
    if c1 > 0: ans -= pc(i+1, c1-1)
    ans %= MOD

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

class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        res = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                res = f(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = f(dat[r], res)
            l >>= 1
            r >>= 1
        return res


def gcd(x, y):
    if x * y == 0:
        return x + y
    elif x > y:
        return gcd(y, x)
    else:
        return gcd(y % x, x)


N = int(input())
A = [int(_) for _ in input().split()]
ST = SegmentTree(array=A, f=gcd, ti=0)
ans = 0
for i in range(N):
    ans = max(ans, gcd(ST.query(0, i), ST.query(i + 1, N)))
print(ans)


### FIXED CODE ###

import itertools
N = int(input())
A = [int(_) for _ in input().split()]
gcd = lambda x, y: gcd(y, x % y) if x % y else y
L = list(itertools.accumulate(A, func=gcd))
R = list(itertools.accumulate(A[::-1], func=gcd))[::-1]
ans = max(R[1], L[-2])
for i in range(1, N - 1):
    ans = max(ans, gcd(L[i - 1], R[i + 1]))
print(ans)
# https://img.atcoder.jp/abc125/editorial.pdf