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

#import numpy as np

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)#わるほう
remove_list = []

kouho = [x for x in set(A) if A.count(x) == 1]
#target = kouho[:]
if kouho != []:
    maxA = max(kouho)

for i in range(len(A)):
    if kouho == []:
        break
    maxN = int(maxA/A[i])
    for n in range(2,maxN+1):
        buf = A[i]*n
        if buf in kouho:
            remove_list.append(buf)
            #print(A[i]*n)
#target = kouho[:]
kouho = list(set(kouho) - set(remove_list))
print(len(kouho))

### FIXED CODE ###

#import numpy as np

N = int(input())
A = list(map(int, input().split()))
A.sort()#わるほう

#kouho = sorted([x for x in set(A) if A.count(x) == 1])
#maxA = 10**5

#target = kouho[:]
maxA = A[-1]
work=[0]*(A[-1]+1)

for i in range(len(A)):
    if work[A[i]]<=1:
        maxN = int(maxA/A[i])
        for n in range(1,maxN+1):
            buf = A[i]*n
            #remove_list.append(buf)
            work[buf]+=1
                #print(A[i]*n)

#target = kouho[:]
#kouho = list(set(kouho) - set(remove_list))

sm=0
for s in A:
    if work[s]==1: sm+=1
print(sm)

#print(len(kouho))
### BUGGY CODE ###

S = input()
N = len(S)
ans = 0
for i in range(N-3):
    t = S[i]
    for j in range(i+1, N):
        t += S[j]
        if int(t) % 2019 == 0:
            # print(i + 1, j + 1)
            ans += 1
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

S = input()
N = len(S)
P = 2019
if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
    sys.exit()

num = [0] * P
num[0] = 1
now, ans = 0, 0
_10 = 1
for i in range(N-1, -1, -1):
    now = (now + int(S[i]) * _10) % P
    _10 *= 10
    _10 %= P
    ans += num[now]
    num[now] += 1

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

n, k = map(int, input().split())
scs = list(map(int, input().split()))
#print(scs)

res = []
re = 1
pre = 0

for i in range(n - k + 1):
    for j in range(k):
        re = re * scs[i + j]
   
    if i > 0:
        if pre < re:
            print("Yes")
        else:
            print("No")
    pre = re
    re = 1

### FIXED CODE ###

n, k = map(int, input().split())
scs = list(map(int, input().split()))

for i in range(k, n):
    if  scs[i] > scs[i - k]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import sys
import numpy as np
input = sys.stdin.readline
 
MOD = 10**9 + 7
U = 2 ** 20
 
N = int(input())
A = [int(x) for x in input().split()]
 
arr_0 = np.ones(U,dtype=np.int64)
arr_1 = np.zeros(U,dtype=np.int64)
 
zero_update = [0] * U #0が出てきて更新した回数
zero_cnt = 0
 
c = 0
for a in A:
  c ^= a
  if c == 0:
    zero_cnt += 1
    continue
  n = zero_cnt - zero_update[c]
  zero_update[c] = zero_cnt
  a = arr_0[c]
  b = arr_1[c]
  a,b = a+n*b,b
  a,b = a,a+b
  a %= MOD
  b %= MOD
  arr_0[c] = a
  arr_1[c] = b
 
answer = 0
if c != 0:
  answer = arr_0[c]
else:
  answer = arr_1[1:].sum()
  answer += pow(2,zero_cnt-1,MOD)
  answer %= MOD
print(answer)


### FIXED CODE ###

import sys
input = sys.stdin.readline
 
MOD = 10**9 + 7
U = 2 ** 20
 
N = int(input())
A = [int(x) for x in input().split()]
 
arr_0 = [1] * U
arr_1 = [0] * U
 
zero_update = [0] * U #0が出てきて更新した回数
zero_cnt = 0
 
c = 0
for a in A:
  c ^= a
  if c == 0:
    zero_cnt += 1
    continue
  n = zero_cnt - zero_update[c]
  zero_update[c] = zero_cnt
  a = arr_0[c]
  b = arr_1[c]
  a,b = a+n*b,b
  a,b = a,a+b
  a %= MOD
  b %= MOD
  arr_0[c] = a
  arr_1[c] = b
 
answer = 0
if c != 0:
  answer = arr_0[c]
else:
  answer = sum(arr_1[1:])
  answer += pow(2,zero_cnt-1,MOD)
  answer %= MOD
print(answer)
### BUGGY CODE ###

def MAIN():
    H, W = map(int, input().split())
    MAP = tuple(input() for _ in range(H))
    R, C = map(int, input().split())
    PTN = tuple(input() for _ in range(R))
    def solve(a, b):
        k = 0
        for i in range(a, a + R):
            if MAP[i][b:b + C] == PTN[k]:
                k += 1
            else:
                return False
        return True
    ans = []
    for i in range(H - R + 1):
        for j in range(W - C + 1):
            if solve(i, j):
                ans.append(f"{i} {j}")
    if ans:
        print(*ans, sep="\n")
MAIN()



### FIXED CODE ###

base1 = 1009
base2 = 1013
mask = (1 << 32) - 1
def calc_hash(f, r, c):
    global ph, pw, h
    tmp = [[0] * c for _ in range(r)]
    dr, dc = r - ph, c - pw
    # t1 = 1
    t1 = (base1 ** pw) & mask
    # for _ in range(pw):
        # t1 = (t1 * base1) & mask
    for i in range(r):
        e = 0
        for j in range(pw):
            e = e * base1 + f[i][j]
        for j in range(dc):
            tmp[i][j] = e
            e = (e * base1 - t1 * f[i][j] + f[i][j + pw]) & mask
        tmp[i][dc] = e
    t2 = 1
    for _ in range(ph):
        t2 = (t2 * base2) & mask
    for j in range(dc + 1):
        e = 0
        for i in range(ph):
            e = e * base2 + tmp[i][j]
        for i in range(dr):
            h[i][j] = e
            e = (e * base2 - t2 * tmp[i][j] + tmp[i + ph][j]) & mask
        h[dr][j] = e
th, tw = map(int, input().split())
t = tuple(tuple(ord(c) for c in input()) for _ in range(th))
ph, pw = map(int, input().split())
p = tuple(tuple(ord(c) for c in input()) for _ in range(ph))
ans = []
if th >= ph and tw >= pw:
    h = [[0] * tw for _ in range(th)]
    calc_hash(p, ph, pw)
    key = h[0][0] & mask
    calc_hash(t, th, tw)
    for i in range(th - ph + 1):
        for j in range(tw - pw + 1):
            if h[i][j] & mask == key:
                ans.append(f"{i} {j}")
if ans:
    print("\n".join(a for a in ans))
### BUGGY CODE ###

n=int(input())
p=list(map(float, input().split()))
ans=0
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n+1):
    for j in range(1,n+1):
        if i==0:
            dp[i][j]=dp[i][j-1]*(1-p[j-1])
        else:
            dp[i][j]=p[j-1]*dp[i-1][j-1]+(1-p[j-1])*dp[i][j-1]

for i in range(n//2+1,n+1):
    ans+=dp[i][n]
print(ans)

### FIXED CODE ###

n=int(input())
p=list(map(float, input().split()))
ans=0
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n+1):
    for j in range(1,n+1):
        if i==0:
            dp[i][j]=dp[i][j-1]*(1-p[j-1])
        else:
            dp[i][j]=p[j-1]*dp[i-1][j-1]+(1-p[j-1])*dp[i][j-1]

for i in range(n//2+1,n+1):
    ans+=dp[i][n]
print(ans)
### BUGGY CODE ###

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


t=sorted(s)

if t[0]==0:
  print(0)
  exit()
count=1
for i in range(0,n):
  count=count*t[i]
if count>10**18:
  print(-1)
else:
  print(count)

### FIXED CODE ###

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


t=sorted(s)

if t[0]==0:
  print(0)
  exit()
count=1
for i in range(0,n):
  count=count*t[i]
  if count>10**18:
    print(-1)
    exit()

print(count)
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

K = int(readline())
S = readline().rstrip()
S = len(S)
N = K + S

DIV = 10 ** 9 + 7

# K = 3, S = 5のとき
# ..X.X.X.
# Xが取る3か所を選んだ上で、
# 最も右のXよりも右のマス：各26通り
# 最も右のXを含む、それより左のマス：Xのマスは1通り、それ以外は各25通り
# 最も右のXが
# ..X.....　の状態から、
# .......X  
# の状態について、場合の数を求める

ans = 0
ncr = 1
div = 1
mul = S - 1
for xpos in range(S, N + 1):
  # xpos箇所からK箇所を選ぶ場合の数
  # 一番右に1個固定した状態で、残りのxpos - 1か所からS - 1個を選ぶ
  pat = ncr
#  print("xpos",xpos,"ncr",ncr)
  mul += 1
  ncr = ncr * mul // div
  div += 1
#  print(S,"from",xpos,"pat",pat)
  # その場合の数に対して、X以外の文字の選び方は25 ** (X - S)通りある
#  print("25 for",xpos - S,"boxes")
  pat *= pow(25, xpos - S, DIV)
  pat %= DIV
  
  # 残りのマスに対しては26通りずつ選べる
#  print("26 for ",N - xpos,"boxes")
  pat *= pow(26, N - xpos, DIV)
  pat %= DIV
#  print("xpos",xpos,"pat",pat)
  
  ans += pat
  ans %= DIV

print(ans)

### FIXED CODE ###

import sys
readline = sys.stdin.readline

K = int(readline())
S = readline().rstrip()
S = len(S)
N = K + S

DIV = 10 ** 9 + 7
n = (10 ** 6) * 5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % DIV )
    inverse.append( ( -inverse[DIV % i] * (DIV//i) ) % DIV )
    g2.append( (g2[-1] * inverse[-1]) % DIV )

def nCr(n, r, DIV):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % DIV

# K = 3, S = 5のとき
# ..X.X.X.
# Xが取る3か所を選んだ上で、
# 最も右のXよりも右のマス：各26通り
# 最も右のXを含む、それより左のマス：Xのマスは1通り、それ以外は各25通り
# 最も右のXが
# ..X.....　の状態から、
# .......X  
# の状態について、場合の数を求める

ans = 0
for xpos in range(S, N + 1):
  # xpos箇所からK箇所を選ぶ場合の数
  # 一番右に1個固定した状態で、残りのxpos - 1か所からS - 1個を選ぶ
  pat = nCr(xpos - 1, S - 1, DIV)
#  print("xpos",xpos,"ncr",ncr)
#  print(S,"from",xpos,"pat",pat)
  # その場合の数に対して、X以外の文字の選び方は25 ** (X - S)通りある
#  print("25 for",xpos - S,"boxes")
  pat *= pow(25, xpos - S, DIV)
  pat %= DIV
  
  # 残りのマスに対しては26通りずつ選べる
#  print("26 for ",N - xpos,"boxes")
  pat *= pow(26, N - xpos, DIV)
  pat %= DIV
#  print("xpos",xpos,"pat",pat)
  
  ans += pat
  ans %= DIV

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

N, W = map(int, input().split())
v = [0]*(N+1); w = [0]*(N+1)
for i in range(1, N+1):
    a, b = map(int, input().split())
    w[i], v[i] = a, b

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1, N+1):
    row = dp[i]; row_before = dp[i-1]
    v_i = v[i]; w_i = w[i]
    for sum_w in range(1, W+1):
        if sum_w - w_i >= 0:
            row[sum_w] = max(row_before[sum_w - w_i] + v_i, row_before[sum_w])
        else:
            row[sum_w] = row_before[sum_w]
print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
v = [0]*(N+1); w = [0]*(N+1)
for i in range(1, N+1):
    a, b = map(int, input().split())
    w[i], v[i] = a, b

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1, N+1):
    row = dp[i]; row_before = dp[i-1]
    v_i = v[i]; w_i = w[i]
    for sum_w in range(1, W+1):
        if sum_w - w_i >= 0:
            row[sum_w] = max(row_before[sum_w - w_i] + v_i, row_before[sum_w])
        else:
            row[sum_w] = row_before[sum_w]
print(dp[N][W])
### BUGGY CODE ###

import math
a = 0
n = int(input())

def ggcd(i, j, k):
    a = math.gcd(i, j)
    b = math.gcd(k, a)
    return b

for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            a += ggcd(i, j, k)

print(a)

### FIXED CODE ###

import math
a = 0
n = int(input())

def ggcd(i, j, k):
    a = math.gcd(i, j)
    b = math.gcd(k, a)
    return b

for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            a += ggcd(i, j, k)

print(a)
### BUGGY CODE ###

N = int(input())

A = []
for _ in range(N):
    a = int(input())
    A.append(a)
    
BALL = A[:]

from collections import defaultdict
COLOR = defaultdict(lambda: -1)

for b in BALL:
    i = 0
    while True:
        if COLOR[i] < b:
            COLOR[i] = b
            break
        i += 1
            
#print(COLOR)
print(len(COLOR))


### FIXED CODE ###

N = int(input())

A = []
for _ in range(N):
    a = int(input())
    A.append(a)
    
nums = A[:]
colors = [float('inf')] * N

from bisect import bisect_left, bisect_right, insort_right
ans = 0
for n in nums:
    idx = bisect_right(colors, -n)
    colors[idx] = -n
    #print(ans)
    if idx > ans:
        ans = idx
    #print(idx, colors)
            
print(ans+1)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
	l = list(map(int,input().split()))
	A.append([i-1 for i in l])
match_num = [0 for i in range(N)]
match_dict = {}
idx = 0
for i in range(N-1):
	for j in range(i+1, N):
		match_dict[(i,j)] = idx
		idx += 1
M = idx
edge = [[] for i in range(M)]
parent = [[] for i in range(M)]
for i in range(N):
	for j in range(N-2):
		a = A[i][j]
		a_nxt = A[i][j+1]
		x,y = min(i,a), max(i,a)
		z,w = min(i,a_nxt), max(i,a_nxt)
		m1 = match_dict[(x,y)]
		m2 = match_dict[(z,w)]
		edge[m1].append(m2)
		parent[m2].append(m1)
finish = [False for i in range(M)]
candidate = [i for i in range(M) if len(parent[i]) == 0]
depth = [-1 for i in range(M)]

# circuit check
search = [c for c in candidate]
edge_copy = [[e for e in edge[i]] for i in range(M)]
parent_copy = [[p for p in parent[i]] for i in range(M)]
while len(search) > 0:
	s = search.pop()
	del_list = []
	for e in edge_copy[s]:
		parent_copy[e].remove(s)
		if len(parent_copy[e]) == 0:
			search.append(e)
			del_list.append(e)
	for e in del_list:
		edge_copy[s].remove(e)
if sum([len(parent_copy[i]) for i in range(M)]) > 0:
	print(-1)
	exit()

day = 0
while len(candidate) > 0:
	new_candidate = []
	for c in candidate:
		for e in edge[c]:
			parent[e].remove(c)
			if len(parent[e]) == 0:
				new_candidate.append(e)
		edge[c] = []
	candidate = new_candidate
	day += 1
print(day)

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
	l = list(map(int,input().split()))
	A.append([i-1 for i in l])
match_num = [0 for i in range(N)]
match_dict = {}
idx = 0
for i in range(N-1):
	for j in range(i+1, N):
		match_dict[(i,j)] = idx
		idx += 1
M = idx
edge = [[] for i in range(M)]
parent = [[] for i in range(M)]
for i in range(N):
	for j in range(N-2):
		a = A[i][j]
		a_nxt = A[i][j+1]
		x,y = min(i,a), max(i,a)
		z,w = min(i,a_nxt), max(i,a_nxt)
		m1 = match_dict[(x,y)]
		m2 = match_dict[(z,w)]
		edge[m1].append(m2)
		parent[m2].append(m1)
finish = [False for i in range(M)]
candidate = [i for i in range(M) if len(parent[i]) == 0]
depth = [-1 for i in range(M)]


day = 0
while len(candidate) > 0:
	new_candidate = []
	for c in candidate:
		finish[c] = True
		for e in edge[c]:
			parent[e].remove(c)
			if len(parent[e]) == 0:
				new_candidate.append(e)
		edge[c] = []
	candidate = new_candidate
	day += 1
print(day if all(finish) else -1)
### BUGGY CODE ###

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

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if S[i] == S[j]:
            if i != 0:
                if S[i-1] == S[j-1]:
                    continue
            equal = 1
            for k in range(1, min(j-i, N-j)):
                if S[i+k] == S[j+k]:
                    equal += 1
                else:
                    break
            ans = max(ans, equal)

print(ans)


### FIXED CODE ###

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

dp = [[0] * (N+1) for _ in range(N+1)]

for i in range(N-1, -1, -1):
    for j in range(N-1, -1, -1):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        now = min(dp[i][j], j-i)
        ans = max(ans, now)

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

import sys
import math
from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

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

N = II()
S = input()

ans = 0
for i in range(1, N-2):
    for j in range(2, N):
        if j <= i:
            continue
        for k in range(3, N+1):
            if k <= j:
                continue
            if j-i != k-j and S[i-1] != S[j-1] and S[i-1] != S[k-1] and S[k-1] != S[j-1]:
                ans+=1
print(ans)

### FIXED CODE ###

import sys
import math
from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

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

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
  for j in range(i+1,N-1):
    k=2*j-i
    if k>=N:
      continue
    if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
      ans-=1
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import math
import re
S = str(input())

S = S.replace('?','.')

MOD = 1000000007
count = 0
for i in range(10**(len(S))):
    match_result = re.match(S, str(i).zfill(len(S)))
    if match_result is None:
        continue
    if i % 13 == 5:
        count += 1

print(count%MOD)

### FIXED CODE ###

S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [0] * 13 
dp[0] = 1
mul = 1
for i in range(0, N):
    next_dp = [0] * 13
    if S[N - i - 1] == '?':
        next_dp = [sum(dp[(j - k * mul) % 13] for k in range(10)) for j in range(13)]
    else:
        for j in range(13):
            k = int(S[N - i - 1])
            next_dp[(j + k * mul) % 13] = dp[j]
    dp = [d % MOD for d in next_dp]
    mul *= 10
    mul %= 13

print(dp[5])
### BUGGY CODE ###

import bisect

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

count = 0
a1 = sorted(a)
b1 = sorted(b)
c1 = sorted(c)
for i in c1:
    prior_c = bisect.bisect_left(b1,i)
    prior_c_list = b1[:prior_c]
    for j in prior_c_list:
        count += bisect.bisect_left(a1,j)

print(count)

### FIXED CODE ###

import bisect

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

a1 = sorted(a)
c1 = sorted(c)
count = 0

for i in b:
    count += bisect.bisect_left(a1,i) * (n - bisect.bisect_right(c1,i))
    
print(count)
### BUGGY CODE ###

N, M = map(int, input().split())
A = []
for _ in range(M):
  A.append(int(input()))

div = 1e9 + 7
ans = 0
prev1 = 1
prev2 = 0

for n in range(1, N+1):
  if n in A:
    path = 0
  else:
    path = int((prev1 + prev2) % div)

  prev1, prev2 = path, prev1

print(path)

### FIXED CODE ###

N, M = map(int, input().split())
skip = [False] * (N+1)
for _ in range(M):
  skip[int(input())] = True

div = 1e9 + 7
path = 0
prev1 = 1
prev2 = 0

for n in range(1, N+1):
  if skip[n]:
    path = 0
  else:
    path = int((prev1 + prev2) % div)

  prev1, prev2 = path, prev1

print(path)
### BUGGY CODE ###

N = int(input())

total = 0

while N > 0:
  total += N % 10
  N = N // 10
  
if total % 9 == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

if sum([int(s) for s in list(input().split())]) % 9 == 0:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

x = int(input())
primes = [2]
if x != 2:
    for i in range(3, x, 2):
        prime_flg = True
        for num in primes:
            if i % num == 0:
                prime_flg = False
            else:
                pass
        if prime_flg == True:
            primes.append(i)
target = x
ans = 0
if x != 2:
    while(True):
        prime_flg = True
        for num in primes:
            if target % num == 0:
                prime_flg = False
            else:
                pass
        if prime_flg == True:
            ans = target
            break
        else:
            target += 1
else:
    ans = 2
print(ans)


### FIXED CODE ###

import math
x = int(input())

ceil_num = math.ceil(math.sqrt(x))


def is_prime(n):
    if n <= 1:
        return False
    else:
        pass
    for i in range(2, ceil_num):
        if n % i == 0:
            return False
    else:
        return True

while(is_prime(x)==False):
    x += 1
ans = x
print(ans)
### BUGGY CODE ###

from functools import reduce
from operator import mul

N = int(input())
AS = [int(i) for i in input().split()]

m = reduce(mul, AS, 1)
if m > 10**18:
  print('-1')
else:
  print(m)


### FIXED CODE ###

N = int(input())
AS = [int(i) for i in input().split()]

m = 10 ** 18
acc = 1
if 0 in AS:
  print(0)
  import sys
  sys.exit()

for i in AS:
  acc *= i
  if acc > m:
    print('-1')
    import sys
    sys.exit()

print(acc)
### BUGGY CODE ###

import itertools
K,S=map(int,input().split())
lst=[num for num in range(K+1)]
ans=0
for i in itertools.product(lst,repeat=3):
  if sum(i)==S:
    ans+=1
print(ans)

### FIXED CODE ###

import itertools
K,S=map(int,input().split())
ans=0
for i in range(K+1):
  for j in range(K+1):
    if i+j<=S and S-(i+j)<=K:
      #print(i,j)
      ans+=1
print(ans)
### BUGGY CODE ###

import fractions

MOD = 1000000007
N = int(input())
A = list(map(int,input().split()))
#print(math.gcd(5,4))

LCM = A[0]
for i in range(0,N-1,1):
    LCM = LCM*A[i+1]//fractions.gcd(A[i+1],LCM)
B = [0 for i in range(0,N,1)]
for i in range(0,N,1):
    B[i]= (LCM//A[i])%MOD

ans = 0
for i in range(0,N,1):
    ans = (B[i] + ans)%MOD

print(ans)

### FIXED CODE ###

def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y

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

LCM = A[0]
for i in range(0,N-1,1):
    LCM = lcm(LCM,A[i+1])
B = [0 for i in range(0,N,1)]
for i in range(0,N,1):
    B[i]= (LCM%MOD)*pow(A[i],MOD-2,MOD)%MOD

ans = 0
for i in range(0,N,1):
    ans = (B[i] + ans)%MOD

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

N = int(input())
S = str(input())
R = []
G = []
B = []
answer = 0
for i in range(N):
    if S[i] == 'R':
        R.append(i)
    if S[i] == 'G':
        G.append(i)
    if S[i] == 'B':
        B.append(i)
for r in R:
    for g in G:
        for b in B:
            X = [r, g, b]
            X.sort()
            if int(X[1]) - int(X[0]) != int(X[2]) - int(X[1]):
                answer += 1
print(answer)

### FIXED CODE ###

N = int(input())
S = str(input())
R = 0
G = 0
B = 0
Z = 0
for i in range(N):
    if S[i] == 'R':
        R += 1
    if S[i] == 'G':
        G += 1
    if S[i] == 'B':
        B += 1

for i in range(N-1):
    for j in range(i+1, N):
        k = 2 * j - i
        if k > N-1:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            Z += 1
print(R*G*B-Z)
### BUGGY CODE ###

k = int(input())
#k = 2

num = 1 
n = 7
x = True
 
if (k%2 == 0):
  x = False
  print(-1)

while x:
  if (n%k == 0):
    print(num)
    break
  else:
    n = n*10 + 7
    num += 1





### FIXED CODE ###

def main():
    k = int(input())

    num = 1 
    n = 7
    
    if (k%2 == 0):
        print(-1)
        return
    

    for i in range(1000000):
        if (n%k == 0):
            print(num)
            return
        else:
            n = (n*10 + 7)%k
            num += 1

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

A,B,X=map(int,input().split())
ans=0
for k in range(A,B+1):
    if k%X==0:
        ans +=1
print(ans)

### FIXED CODE ###

A,B,X=map(int,input().split())
a=A%X
b=B%X
if a!=0:
    A=A+X-a
if b!=0:
    B=B-b
print((B-A)//X+1)
### BUGGY CODE ###

n = int(input())
xlist = [int(input()) for i in range(n)]
a = max(xlist)
for i in range(n):
  if xlist[i] != a:
    print(a)
  else:
    b = xlist[i]
    xlist.pop(i)
    print(max(xlist))
    xlist.insert(i,b)

### FIXED CODE ###

n = int(input())
xlist = [int(input()) for i in range(n)]
ylist = sorted(xlist)
max1 = ylist[-1]
max2 = ylist[-2]
for i in range(n):
  if xlist[i] != max1:
    print(max1)
  else:
    print(max2)