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

n = int(input())
a = list(reversed([int(input()) for i in range(n+1) ]))

prime = [2,3]

for i in range(5,100000):
    f = True
    for p in prime:
        if(p*p > i):break
        if i % p == 0 :
            f = False
            break
    if f :prime.append(i)

def gcd(x,y):
    if(x < y): x,y = y,x
    if(y == 0): return x
    return gcd(y,x % y)

def isprime(x):
    f = True
    for p in prime:
        if(p*p > x):break
        if x % p == 0:
            f = False
            break
    return f

g = 0
for i in a:
    g = gcd(abs(i),g)



for p in prime:
    if (p > n):break
    m = [0 for i in range(p-1)]
    for i in range(n+1):
        m[i % (p-1)] += (a[i] % p)
    f = True
    for i in m:
        if i % p > 0 :
            f = False
            break    
    if f:print(p)




for p in prime:
    if g == 1:break
    if(g % p == 0):
        g //= p
        if (p > n):print(p)

if(g != 1):
    if isprime(g):print(g)

### FIXED CODE ###

n = int(input())
a = list(reversed([int(input()) for i in range(n+1) ]))

prime = [2,3]

for i in range(5,100000):
    f = True
    for p in prime:
        if(p*p > i):break
        if i % p == 0 :
            f = False
            break
    if f :prime.append(i)

def gcd(x,y):
    if(x < y): x,y = y,x
    if(y == 0): return x
    return gcd(y,x % y)

def isprime(x):
    f = True
    for p in prime:
        if(p*p > x):break
        if x % p == 0:
            f = False
            break
    return f

g = 0
for i in a:
    g = gcd(abs(i),g)



for p in prime:
    if (p > n+1):break
    m = [0 for i in range(p-1)]
    if a[0] % p != 0:continue
    for i in range(n+1):
        m[i % (p-1)] += (a[i] % p)
    f = True
    for i in m:
        if i % p > 0 :
            f = False
            break    
    if f:print(p)




for p in prime:
    if g == 1:break
    if(g % p == 0):
        g //= p
        if (p > n+1):print(p)

if(g != 1):
    if isprime(g):print(g)
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
'''
c=[]
for i in range(n-1):
  if s[i:i+2]=='AC':
    c.append(1)
  else:
    c.append(0)
for i in range(q):
  l,r=map(int,input().split())
  print(sum(c[l-1:r-1]))
'''
for i in range(q):
  l,r=map(int,input().split())
  print(s[l-1:r].count('AC'))

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
c=[0 for _ in range(n)]
p=''
d=0
for i in range(n):
  x=s[i]
  if p=='A' and x=='C':
    d+=1
  p=x
  c[i]=d
for i in range(q):
  ans=0
  l,r=map(int,input().split())
  ans=c[r-1]-c[l-1]

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

S = input()
n = len(S)
a = [0]*(n+1)
l = [0]*2019

a[0] = int(S)
l[a[0]%2019] += 1

for i in range(n):
    a[i+1] = a[i] - int(S[i])*pow(10, n-i-1)
    l[a[i+1]%2019] += 1

print(sum(map(lambda x: x*(x-1)//2, l)))


### FIXED CODE ###

import sys

input = sys.stdin.readline

S = input().rstrip()
n = len(S)
l = [0]*2019
d = 10

t = int(S[n-1])
l[t%2019] += 1

l[0] += 1

for i in range(n-2, -1, -1):
    t += int(S[i])*d%2019
    l[t%2019] += 1 
    d *= 10
    d %= 2019

ans = 0

for i in l:
    ans += i*(i-1)//2

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

A,B,Q=map(int,input().split())
s=[int(input()) for _ in range(A)]
t=[int(input()) for _ in range(B)]

#二分探索関数
def bin_search(x,seq):
    width=[0,len(seq)-1]
    while(width[1]-width[0]>1):
        center=(sum(width)//2)
        if x>=seq[center]:
            width=[center,width[1]]
        else:
            width=[width[0],center]
    if x<=seq[width[0]]:
        return [width[0],width[0]]
    elif x>=seq[width[1]]:
        return [width[1],width[1]]
    else:
        return width

for i in range(Q):
    x=int(input())
    Nb_s=bin_search(x,s)
    Nb_t=bin_search(x,t)
    Nb_s0=s[Nb_s[0]]
    Nb_s1=s[Nb_s[1]]
    Nb_t0=t[Nb_t[0]]
    Nb_t1=t[Nb_t[1]]

    k1=abs(Nb_s0-x)+abs(Nb_t0-Nb_s0)
    k2=abs(Nb_s1-x)+abs(Nb_t0-Nb_s1)
    k3=abs(Nb_s0-x)+abs(Nb_t1-Nb_s0)
    k4=abs(Nb_s1-x)+abs(Nb_t1-Nb_s1)
    k5=abs(Nb_t0-x)+abs(Nb_t0-Nb_s0)
    k6=abs(Nb_t1-x)+abs(Nb_t1-Nb_s1)
    k7=abs(Nb_t0-x)+abs(Nb_t0-Nb_s1)
    k8=abs(Nb_t1-x)+abs(Nb_t1-Nb_s0)
    print(min(k1,k2,k3,k4,k5,k6,k7,k8))

### FIXED CODE ###

inf=10**11
A,B,Q=map(int,input().split())
s=[-inf]+[int(input()) for _ in range(A)]+[inf]
t=[-inf]+[int(input()) for _ in range(B)]+[inf]
x=[[i,int(input())] for i in range(Q)]

x.sort(key=lambda x:x[1])
i,s_i,t_i=0,0,0
ans=[]

for i in range(Q):
    while(1):
        if x[i][1]>=s[s_i]:
            s_i+=1
        else:
            break
    while(1):
        if x[i][1]>=t[t_i]:
            t_i+=1
        else:
            break
    ans.append([x[i][0],x[i][1],s[s_i-1],s[s_i],t[t_i-1],t[t_i]])
ans.sort(key=lambda x:x[0])
for i in range(Q):
    xx=ans[i][1]
    Nb_s0=ans[i][2]
    Nb_s1=ans[i][3]
    Nb_t0=ans[i][4]
    Nb_t1=ans[i][5]

    p1=abs(Nb_s0-xx)
    p2=abs(Nb_s1-xx)
    p3=abs(Nb_t0-xx)
    p4=abs(Nb_t1-xx)
    q1=abs(Nb_t0-Nb_s0)
    q2=abs(Nb_t0-Nb_s1)
    q3=abs(Nb_t1-Nb_s0)
    q4=abs(Nb_t1-Nb_s1)
    print(min(p1+q1,p2+q2,p1+q3,p2+q4,p3+q1,p4+q4,p3+q2,p4+q3))
### BUGGY CODE ###

N=int(input())
A=list(map(int, input().split()))
for num in range(N):
  count = 0
  for i in range(N-1):
    if A[i] == num+1:
      count += 1
  print(count)

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
s=0
for num in range(1, N+1):
  count = 0
  for i in range(s, N-1):
    if A[i] == num:
      count += 1
    else:
      break
  s+=count
  print(count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, W = map(int, input().split())
dp = [0] * (W + 1)

for _ in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        tmp = dp[j-w] + v
        if tmp > dp[j]:
            dp[j] = tmp
print(dp[-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, W = map(int, input().split())
dp = [0] * (W + 1)
def dp_opt(n, w):
    for _ in range(N):
        w, v = map(int, input().split())
        for j in range(W, w-1, -1):
            tmp = dp[j-w] + v
            if tmp > dp[j]:
                dp[j] = tmp
    print(dp[-1])
dp_opt(N,W)
### BUGGY CODE ###

def divisor(x):
    if x==1:
        return 1
    if x==2 or x==3:
        return 2
    count=0
    for i in range(1,(x//2)+1):
        if x%i==0:
            count+=1
    return count+1

n = int(input())
ans=0
for num in range(1,n+1):
    a = 0
    divisors = divisor(num)
    a = num* divisors 
    ans+=a
print(ans)

### FIXED CODE ###

import numpy as np
n=int(input())
num=np.array(list(range(1,n+1)))

x=n//num
ans=num*(x+1)*x/2
print(int(np.sum(ans)))
### BUGGY CODE ###

from collections import deque
import math


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [list(input()) for _ in range(H)]

    d = deque()
    d.append([Ch - 1, Cw - 1])

    cost = [[math.inf for _ in range(W)] for _ in range(H)]
    cost[Ch - 1][Cw - 1] = 0

    while d:
        r, c = d.popleft()

        for dr, dc in [[-1, 0], [1, 0], [0, -1], [0, 1]]:  # 上下左右
            nr = r + dr
            nc = c + dc
            if 0 <= nr < H and 0 <= nc < W and S[nr][nc] == "." and cost[nr][nc] > cost[r][c]:
                cost[nr][nc] = cost[r][c]
                d.appendleft([nr, nc])

        for dr in range(-2, 3, 1):  # ワープ
            for dc in range(-2, 3, 1):
                if dr == 0 and dc == 0:
                    continue
                nr = r + dr
                nc = c + dc
                if 0 <= nr < H and 0 <= nc < W and S[nr][nc] == "." and cost[nr][nc] > cost[r][c] + 1:
                    cost[nr][nc] = cost[r][c] + 1
                    d.append([nr, nc])

    if cost[Dh - 1][Dw - 1] == math.inf:
        ans = -1
    else:
        ans = cost[Dh - 1][Dw - 1]

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [input() for _ in range(H)]

    Q = deque([[Ch - 1, Cw - 1, 0]])  # 座標とワープ回数

    cost = [[-1 for _ in range(W)] for _ in range(H)]  # ワープ回数を記録

    while Q:
        r, c, cnt = Q.popleft()

        if cost[r][c] != -1:  # 訪れたことがある
            continue

        cost[r][c] = cnt

        for dr in range(-2, 3):
            for dc in range(-2, 3):
                nr = r + dr
                nc = c + dc

                if 0 <= nr < H and 0 <= nc < W and S[nr][nc] == ".":
                    if abs(dr) + abs(dc) == 1:  # 上下左右
                        Q.appendleft([nr, nc, cnt])
                    elif abs(dr) + abs(dc) >= 2:  # ワープ
                        Q.append([nr, nc, cnt + 1])

    print(cost[Dh - 1][Dw - 1])


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

import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
MOD = 10**9 + 7
if k == 1:
    print(0)
    exit()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for min_index in range(n-k+1):
    for max_index in range(min_index+k-1, n):
        comb_num = combinations_count(max_index-min_index-1, k-2)
        ans += (a[max_index] - a[min_index]) * comb_num
        ans %= MOD

print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
MOD = 10**9 + 7
if k == 1:
    print(0)
    exit()

mod = 10 ** 9 + 7
fact = [1]
fact_inv = [1]
for i in range(10 ** 5):
    new_fact = fact[-1] * (i + 1) % mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact, mod - 2, mod))


def cmb(n, k, mod=MOD):
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod


for max_index in range(k-1, n):
    ans += a[max_index] * cmb(max_index, k-1)
    ans %= MOD

for min_index in range(0, n-k+1):
    ans -= a[min_index] * cmb(n-(min_index+1), k-1)
    ans %= MOD

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

X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_b_total = [0 for _ in range(X*Y)]
for i in range(X):
    for j in range(Y):
        a_b_total[i*Y+j] = a_list[i] + b_list[j]
a_b_total.sort(reverse = True)
a_b_c_total = [0 for _ in range(min(K,X*Y)*Z)]
for i in range(min(K,X*Y)):
    for j in range(Z):
        a_b_c_total[i*Z+j] = a_b_total[i] + c_list[j]
a_b_c_total.sort(reverse = True)
for i in range(K):
    print(a_b_c_total[i])

### FIXED CODE ###

from heapq import heappush, heappop

# input
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)

#solve
hq = []
arg_hash = {}
val = a_list[0] + b_list[0] + c_list[0]
heappush(hq, (-val,0,0,0))

for i in range(K):
    ans, a, b, c = heappop(hq)
    print(-ans)

    arg_a = (a+1, b, c)
    arg_b = (a, b+1, c)
    arg_c = (a, b, c+1)

    if a < X-1 and arg_a not in arg_hash:
        arg_hash[arg_a] = 1
        heappush(hq, (-(a_list[a+1]+b_list[b]+c_list[c]),)+arg_a)
    if b < Y-1 and arg_b not in arg_hash:
        arg_hash[arg_b] = 1
        heappush(hq, (-(a_list[a]+b_list[b+1]+c_list[c]),)+arg_b)
    if c < Z-1 and arg_c not in arg_hash:
        arg_hash[arg_c] = 1
        heappush(hq, (-(a_list[a]+b_list[b]+c_list[c+1]),)+arg_c)
### BUGGY CODE ###

import heapq
def main():
  N, Q = list(map(int, input().split()))
  STX = tuple(list(map(int, input().split())) for _ in range(N))
  D = tuple([int(input()) for _ in range(Q)])

  L = []
  for s, t, x in STX:
    L.append((x, s - x, t - x))

  L.sort(key = lambda x: x[1])
  q = []
  cnt = 0
  for i in range(Q):
    while cnt < len(L) and D[i] >= L[cnt][1]:
      heapq.heappush(q, L[cnt])
      cnt += 1
    while q != []:
      t = heapq.heappop(q)
      if t[2] > D[i]:
        print(t[0])
        heapq.heappush(q, t)
        break
    else:
      print(-1)

main()


### FIXED CODE ###

import heapq
def main():
  N, Q = list(map(int, input().split()))
  STX = tuple(list(map(int, input().split())) for _ in range(N))
  D = tuple([int(input()) for _ in range(Q)])

  L = []
  for s, t, x in STX:
    L.append((x, s - x, t - x))

  L.sort(key = lambda x: x[1])
  q = []
  cnt = 0
  push = heapq.heappush
  pop = heapq.heappop
  t = []
  for i in range(Q):
    while cnt < len(L) and D[i] >= L[cnt][1]:
      if t != []:
        push(q, t)
        t = []
      push(q, L[cnt])
      cnt += 1
    if t != [] and t[2] > D[i]:
      print(t[0])
    else:
      while q != []:
        t = pop(q)
        if t[2] > D[i]:
          print(t[0])
          break
      else:
        t = []
        print(-1)

main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import numpy as np

input()
A = np.array(list(map(int, input().split())))
N = len(A)
if N <= 2:
    print(max(A))
    exit()

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a%b)

ans = 1
for ptr in range(N):
    li = np.concatenate([A[:ptr], A[ptr+1:]])
    g = li[0]
    for i in li[1:]:
        g = gcd(g,i) if g > i else gcd(i,g)
    ans = max(ans, g)

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

if N <= 2:
    print(max(A))
    exit()

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a%b)

ans = 1
left_gcd = [0]
left_gcd[0] = A[0]
right_gcd = [0]
right_gcd[0] = A[N-1]

for i in range(1,N):
    if left_gcd[i-1] > A[i]:
        left_gcd.append(gcd(left_gcd[i-1], A[i]))
    else:
        left_gcd.append(gcd(A[i], left_gcd[i-1]))
    if right_gcd[i-1] > A[N-1-i]:
        right_gcd.append(gcd(right_gcd[i-1], A[N-1-i]))
    else:
        right_gcd.append(gcd(A[N-1-i], right_gcd[i-1]))
right_gcd.reverse()

g = [left_gcd[N-2], right_gcd[1]]

for i in range(1,N-1):
    l = left_gcd[i-1]
    r = right_gcd[i+1]
    if l > r:
        g.append(gcd(l,r))
    else:
        g.append(gcd(r,l))

print(max(g))
### BUGGY CODE ###

N, M = map(int, input().split())
G = [[] for i in range(N+1)]
x = [0] * (N+1)
visited = [False] * (N+1)

for i in range(M):
    L, R, D = map(int, input().split())
    G[L].append((R, D))
    G[R].append((L, -D))

for i in range(1, N+1):
    if not visited[i]:
        q = G[i]
        visited[i] = True
        while q:
            u, d = q.pop(0)
            if not visited[u]:
                x[u] = d
                visited[u] = True
                for v, d_ in G[u]:
                    q.append((v, d+d_))
            
            else:
                if x[u] != d:
                    print('No')
                    exit()
print('Yes')

### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
G = [deque() for i in range(N+1)]
x = [0] * (N+1)
visited = [True] * (N+1)

for i in range(M):
    L, R, D = map(int, input().split())
    G[L].append((R, D))
    G[R].append((L, -D))
    visited[L] = False
    visited[R] = False
    
for i in range(1, N+1):
    if not visited[i]:
        q = G[i]
        visited[i] = True
        
        while q:
            u, d = q.pop()
            
            for v, d_ in G[u]:
                if visited[v]:
                    if x[v] != d+d_:
                        print('No')
                        exit()
                else:
                    visited[v] = True
                    x[v] = d+d_
                    q.append((v, d+d_))
print('Yes')
### BUGGY CODE ###

N = int(input())
A = list()
B = [0] * 200000

for i in range(N):
  i = int(input())
  A.append(i)

for k in range(N):
  if max(A) != A[k]:
    print(max(A))
  else:
    B[k] = A[k]
    A[k] = 0
    print(max(A))
    A[k] = B[k]

### FIXED CODE ###

N = int(input())
A = list()

for i in range(N):
  i = int(input())
  A.append(i)
  
ma = max(A)
sa = sorted(A)

for k in range(N):
  if ma != A[k]:
    print(ma)
  else:
    print(sa[-2])
### BUGGY CODE ###

import numpy as np

#N = 39
#S = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"
N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = len(S.replace("R", "").replace("G", ""))
b = N - r - g
 
ans = r * g * b
 
is_break = False
for i in range(N):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
        if (0 <= i) & (i < j) & (j < k) & (k < N):
            s = S[i] + S[j] + S[k]
            if ("R" in s) & ("G" in s) & ("B" in s):
                    ans -= 1
print(ans)


### FIXED CODE ###


#S = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"# * 1000
#N = len(S)

N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g
 
ans = r * g * b
 
is_break = False
for i in range(N):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
        if k < N:
            s = S[i] + S[j] + S[k]
            if ("R" in s) & ("G" in s) & ("B" in s):
                    ans -= 1

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

n = int(input())

ans = 0
u_l = []
for _ in range(n):
    s = input()
    if s not in u_l:
        u_l.append(s)
        ans += 1
print(ans)


### FIXED CODE ###

n = int(input())

l = [input() for _ in range(n)]
print(len(set(l)))
### BUGGY CODE ###

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

count = N
Sum = 0

for l in range(0, N-1):
    Sum = A[l]
    for r in range(l+1, N):
        if Sum + A[r] != Sum ^ A[r]:
            #print(l,r)
            count -= 1
            break
        else:
            Sum += A[r]
            #count += 1
    count += r-l
print(count)

### FIXED CODE ###

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

count = 0
Sum = 0
r = 0

for l in range(0, N):
    #Sum = A[l]
    while r < N and Sum + A[r] == Sum ^ A[r]:
            Sum += A[r]
            r += 1
    count += r-l
    if(l==r):
        r+=1
    else:
        Sum -= A[l]
    
    
print(count)
### BUGGY CODE ###

#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from random import randrange
from bisect import bisect
from time import perf_counter

def resolve():
    tick = perf_counter() + 1.95
    it = map(int, sys.stdin.read().split())
    D = next(it)
    C = [next(it) for i in range(26)]
    S = [[next(it) for i in range(26)] for i in range(D)]
    L = [[-1] for i in range(26)]
    T = [0] * D

    def update(di, qi):
        T1, L1 = T[:], L[:]

        score = 0
        t0 = T[di]
        score += S[di][qi]-S[di][t0]
        T1[di] = qi

        L1[t0] = li = L[t0][:]
        ii = li.index(di)
        la = D if len(li)-1 == ii else li[ii+1]
        score -= C[t0] * (di-li[ii-1])*(la-di)
        li.pop(ii)

        L1[qi] = li = L[qi][:]
        ii = bisect(li, di)
        li.insert(ii, di)
        la = D if len(li)-1 == ii else li[ii+1]
        score += C[qi] * (di-li[ii-1])*(la-di)

        return score, T1, L1

    score = 0
    x = (1+D)*D//2
    for i in range(D):
        score += S[i][0]
        L[0].append(i)

    for i in range(1, 26):
        score -= C[i] * x


    while perf_counter() < tick:
        diff, T1, L1 = update(randrange(0, D), randrange(0, 26))
        if diff > 0:
            score += diff
            T, L = T1, L1

    print(*(i+1 for i in T), sep="\n")

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    D = next(it)
    C = [next(it) for i in range(26)]
    S = [[next(it) for i in range(26)] for i in range(D)]

    ans = []
    for i in range(D):
        ss = S[i]
        di, qi = 0, ss[0]
        for j in range(1, 26):
            if ss[j] > qi:
                di, qi = j, ss[j]
        ans.append(di+1)

    print(*ans, sep="\n")

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

def main():
    n=int(input())
    aa=map(int,input().split())
    x=1
    for a in aa:
        x*=a
    if x>1000000000000000000:
        print(-1)
    else:
        print(x)
main()

### FIXED CODE ###

def main():
    n=int(input())
    aa=map(int,input().split())
    x=1
    for a in aa:
        if a == 0:
            print(0)
            return
        if x<1000000000000000000:
            x*=a
    if x>1000000000000000000:
        print(-1)
    else:
        print(x)
main()
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=[]
for _ in range(n):
    aa.append(int(input()))
for i in range(n):
    print(max(aa[:i] + aa[i+1:]))

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=[]
for i in range(n):
    aa.append(int(input()))
ma = max(aa)
if aa.count(ma) > 1:
    for _ in range(n):
        print(ma)
else:
    for i in range(n):
        if aa[i] != ma:
            print(ma)
        else:
            print(max(aa[:i]+aa[i+1:]))
### BUGGY CODE ###

n=int(input())
p=list(map(int, input().split()))
ans=1
for i in range(1,n):
  flag=True
  for j in range(i):
    if p[i] > p[j]:
      flag=False
      break
  if flag:
    ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
p=list(map(int, input().split()))

ans=1
minn=p[0]
for i in range(1,n):
  minn = min(p[i-1], minn)
  if minn >= p[i]: 
    ans+=1
print(ans)
### BUGGY CODE ###

s = input()
c = 0

for i in range(len(str(s))):
    for j in range(i+1, len(str(s))+1):
        tmp = s[i:j]
        if int(tmp) % 2019 == 0:
            c += 1

print(c)


### FIXED CODE ###

import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)
### BUGGY CODE ###

import math
N=int(input())
# rootを求める
root_n = int(math.sqrt(N))
up_n = root_n
up_ans = 0
keta = lambda x: len(str(x))
while up_n <= N:
  if N % up_n == 0:
    pair = int(N/up_n)
    # 桁数を求める
    up_ans = max(keta(pair), keta(up_n))
    break
  else:
    up_n+=1

print(up_ans)



### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

import math
N=int(input())
INF = 3000000
# rootを求める
# 二分探索すればいいのか！！！
ans = INF
pairs = make_divisors(N)
keta = lambda x: len(str(x))
for pair in pairs:
  tmp_ans = max(keta(pair), keta(int(N/pair)))
  ans = min(ans,tmp_ans)

print(ans)

# root_n = int(math.sqrt(N))
# up_n = root_n
# up_ans = 0

# while up_n <= N:
#   if N % up_n == 0:
#     pair = int(N/up_n)
#     # 桁数を求める
    
#     break
#   else:
#     up_n+=1

# print(up_ans)
### BUGGY CODE ###

N, W = map(int, input().split()) #N個の製品、Wの制限
P = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W + 1) for _ in range(N)]

for j in range(P[0][0], W+1):
    dp[0][j] = P[0][1]

for i in range(1, N):
    for j in range(1, W + 1):
        if j - P[i][0] < 0:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
            continue

        dp[i][j] = max(dp[i-1][j-P[i][0]] + P[i][1],
                       dp[i-1][j],
                       dp[i][j-1])

print(dp[N-1][W])

### FIXED CODE ###

def main(N, W, P):
    dp = [[0]*(W + 1) for _ in range(N)]
    for j in range(P[0][0], W+1):
        dp[0][j] = P[0][1]

    for i in range(1, N):
        for j in range(1, W + 1):
            if j - P[i][0] < 0:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
                continue

            dp[i][j] = max(dp[i-1][j-P[i][0]] + P[i][1],
                           dp[i-1][j])

    print(dp[N-1][W])

if __name__ == "__main__":
    N, W = map(int, input().split()) #N個の製品、Wの制限
    P = [tuple(map(int, input().split())) for _ in range(N)]
    main(N, W, P)