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

import copy



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

for i in range(N):
   # B = copy.deepcopy(A)
    tmp = A[i]
    A[i] = 0
    ans = max(A)
    A[i] = tmp
    print(ans)
             


### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
B = [ [0] * 2 for i in range(N)]

for i in range(N):
    B[i][0] = A[i]
    B[i][1] = i

B.sort(reverse=True)
for i in range(N):
    if B[0][1] == i:
        print(B[1][0])
    else:
        print(B[0][0])
### BUGGY CODE ###

import numpy as np
from numba import njit
import sys

read = sys.stdin.buffer.read


@njit
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(3 ** n):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            r = pow3 % 3
            pow3 //= 3
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")


### FIXED CODE ###

import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")
### BUGGY CODE ###

n = int(input())
A = [int(val) - (i + 1) for i, val in zip(range(n), input().split())]

b = int(round(sum(A) / len(A)))
sad = 0
Sad = []
for j in range(min(A), max(A)+1):
  b_ = j
  for i in range(n):
    sad += abs(A[i] - b_)
  Sad.append(sad)
  sad = 0
print(min(Sad))

### FIXED CODE ###

n = int(input())
A = sorted([int(val) - (i + 1) for i, val in zip(range(n), input().split())])

b = A[len(A)//2]
sad = 0
for i in range(n):
  sad += abs(A[i] - b)
print(sad)
### BUGGY CODE ###

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

pin = []
cnt = 0

for i in range(0, 1000):
    pin.append(str(i).zfill(3))
#print(pin)

for i in range(0, 1000):
    k = 0
    for j in range(len(s)):
        if pin[i][k] == s[j]:
            k += 1
            if k == 3:
                cnt += 1
                break
                
print(cnt)

### FIXED CODE ###

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

pin = []
cnt = 0

for i in range(0, 1000):
    pin.append(str(i).zfill(3))
#print(pin)

for i in range(0, 1000):
    k = 0
    for j in range(len(s)):
        if pin[i][k] == s[j]:
            k += 1
            if k == 3:
                cnt += 1
                break
                
print(cnt)
### BUGGY CODE ###

import copy
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    b = copy.copy(a)
    del b[i]
    b.sort()
    print(b[-1])

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)
### BUGGY CODE ###

import collections as c

h,w,m = map(int,input().split())
x = []
y = []
z = []
for i in range(m):
    s,t = map(int,input().split())
    x.append(s)
    y.append(t)
    z.append(tuple([s,t]))
a = c.Counter(x)
b = c.Counter(y)
a = a.most_common()
b = b.most_common()
c = []
d = []
e = a[0][1]
f = b[0][1]

for sa in a:
    if sa[1] == e:
        c.append(sa[0])
    else:
        break
for sb in b:
    if sb[1] == f:
        d.append(sb[0])
    else:
        break

fl = 0
ans = e+f-1
for s in c:
    for t in d:
        if tuple([s,t]) not in z:
            fl = 1
            ans += 1
            break
    if fl == 1:
        break
    
print(ans)


### FIXED CODE ###

import collections as c

h,w,m = map(int,input().split())
x = []
y = []
z = set([])
for i in range(m):
    s,t = map(int,input().split())
    x.append(s)
    y.append(t)
    z.add(tuple([s,t]))
a = c.Counter(x)
b = c.Counter(y)
a = a.most_common()
b = b.most_common()
c = []
d = []
e = a[0][1]
f = b[0][1]

for sa in a:
    if sa[1] == e:
        c.append(sa[0])
    else:
        break
for sb in b:
    if sb[1] == f:
        d.append(sb[0])
    else:
        break

fl = 0
ans = e+f-1
for s in c:
    for t in d:
        if tuple([s,t]) not in z:
            fl = 1
            ans += 1
            break
    if fl == 1:
        break
    
print(ans)
### BUGGY CODE ###

def mod_cmb(n, r, mod=10 ** 9 + 7):
	assert n >= r >= 0

	def ex_euclid(x, y):
		a, b = 1, 0
		while y != 0:
			a, b = b, (a - x // y * b)
			x, y = y, x % y
		return a

	p = q = 1
	for i in range(n - r + 1, n + 1):
		p *= i
		p %= mod
	for i in range(2, r + 1):
		q *= i
		q %= mod
	p *= ex_euclid(q, mod)
	p %= mod
	return p

N, A, B, K = map(int, input().split())
mod = 998244353
ans = 0
for r in range(N + 1):
	if (K - A * r) % B == 0:
		b = (K - A * r) // B
		if 0 <= b <= N:
			ans += mod_cmb(N, r, mod) * mod_cmb(N, (K - A * r) // B, mod)
			ans %= mod
print(ans)

### FIXED CODE ###

N, A, B, K = map(int, input().split())
mod = 998244353
m = N

fac = [1] * (m + 1)
inv = [1] * (m + 1)
for i in range(1, m + 1):
	fac[i] = fac[i - 1] * i % mod
inv[-1] = pow(fac[-1], mod - 2, mod)
for i in range(m - 1, -1, -1):
	inv[i] = inv[i + 1] * (i + 1) % mod

def cmb(n, r):
	assert n >= r >= 0
	return fac[n] * inv[n - r] * inv[r] % mod

ans = 0
for r in range(N + 1):
	if (K - A * r) % B == 0:
		b = (K - A * r) // B
		if 0 <= b <= N:
			ans += cmb(N, r) * cmb(N, (K - A * r) // B)
			ans %= mod
print(ans)
### BUGGY CODE ###

def main():
    n = int(input())
    #ビット全探索を行う
    import itertools
    li = list(itertools.product([0, 1], repeat=n)) # ０が不親切もの、１が親切もの

    #dd[i]:人iが人xをy（０なら不親切,１なら親切)だと思っていることを収納
    from collections import deque, defaultdict
    dd = {}
    for i in range(n):
        dd[i] = deque()
    for i in range(n):
        a = int(input())
        for j in range(a):
            x, y = map(int, input().split())
            dd[i].append((x-1, y))


    from copy import deepcopy
    max_sum = 0 #親切者の数の最大値
    for i in li: # i には親切者のタプルが入っている
        ppp = 0
        for ggg in i:
            ppp += ggg
        if ppp <= max_sum:
            continue
        sum_ = 0
        co = deepcopy(dd)
        vv = 0
        for k in range(len(i)): #全員の証言が矛盾しないかを考える
            if i[k] == 0: # 不親切ものの場合
                continue
            else: #以下k人目の証言を考える
                sum_ += 1
                length = len(co[k])
                c = 0
                while co[k]:
                    x, y = co[k].popleft()
                    if i[x] != y: #証言と一致していない場合
                        break
                    else:
                        c+=1
                if c == length: #k人目の証言が全てあっている場合
                    vv += 1
        if vv == sum_:
            max_sum = max(max_sum, vv)

    print(max_sum)
            
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    n = int(input())
    #ビット全探索を行う
    import itertools
    li = list(itertools.product([0, 1], repeat=n)) # ０が不親切もの、１が親切もの

    #dd[i][x] = y:人iが人xをy（０なら不親切,１なら親切)だと思っていることを収納
    NIL = -1
    dd = [[NIL]*n for _ in range(n)]
    for i in range(n):
        a = int(input())
        for j in range(a):
            x, y = map(int, input().split())
            x = x-1
            dd[i][x] = y


    from copy import deepcopy
    max_sum = 0 #親切者の数の最大値
    for i in li: # i には親切者のタプルが入っている
        ppp = 0
        for ggg in i:
            ppp += ggg
        if ppp <= max_sum:
            continue
        sum_ = 0
        flag = True
        for k in range(len(i)): #全員の証言が矛盾しないかを考える
            if i[k] == 0: # 不親切ものの場合
                continue
            else: #以下k人目の証言を考える
                sum_ += 1
                for l in range(n):
                    if dd[k][l] != NIL and dd[k][l] != i[l]: #証言と一致していない場合
                        flag = False
                        break
        if flag:
            max_sum = max(max_sum, sum_)

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

n = int(input())
li = list(map(int,input().split()))
ans = []
for i in range(n):
    ans.append(li[i])
    ans = ans[::-1]
print(*ans)

### FIXED CODE ###

from collections import deque

N = int(input())
numbers = input().split()

d = deque()

for i in range(N):
    if i % 2 == 0:
        d.append(numbers[i])
    else :
        d.appendleft(numbers[i])
        
if N % 2 == 1:
    d.reverse()
    
output = ' '.join(d)

print(output)
### BUGGY CODE ###

# 上からm番目がx
# x以上のヒトがm人以上、x+1以上のヒトがm-1人以下
# x以上のヒトがm人以上となる最大のx
from bisect import bisect_left
from itertools import accumulate

n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ok = 0
ng = 10 ** 15

B = [0] + A[::-1]
C = list(accumulate(B))

while ng - ok > 1:
    mid = (ok + ng) // 2
    cnt = 0
    for i in range(n):
        gendo = mid - A[i]
        position = bisect_left(A, gendo)
        if position == n:
            continue
        kosuu = n - position
        cnt += kosuu
    if cnt >= m:
        ok = mid
    else:
        ng = mid
ans = 0
cnt = m
for i in range(n):
    gendo = ok - A[i]
    position = bisect_left(A, gendo)
    if position == n:
        continue
    kosuu = n - position
    ans += C[kosuu] + kosuu * A[i]
    cnt -= kosuu
ans += cnt * ok
print(ans)


### FIXED CODE ###

# 上からm番目がx
# x以上のヒトがm人以上、x+1以上のヒトがm-1人以下
# x以上のヒトがm人以上となる最大のx
from bisect import bisect_left
from itertools import accumulate
import sys

input = sys.stdin.buffer.readline


n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ok = 0
ng = 3 * (10 ** 5)

B = [0] + A[::-1]
C = list(accumulate(B))

while ng - ok > 1:
    mid = (ok + ng) // 2
    cnt = 0
    for i in range(n):
        gendo = mid - A[i]
        position = bisect_left(A, gendo)
        if position == n:
            continue
        kosuu = n - position
        cnt += kosuu
    if cnt >= m:
        ok = mid
    else:
        ng = mid
ans = 0
cnt = m
for i in range(n):
    gendo = ok - A[i]
    position = bisect_left(A, gendo)
    if position == n:
        continue
    kosuu = n - position
    ans += C[kosuu] + kosuu * A[i]
    cnt -= kosuu
ans += cnt * ok
print(ans)
### BUGGY CODE ###

from collections import Counter

def main():
    N, *A = map(int, open(0).read().split())

    ctr = Counter(A)
    memo = []
    dp = set()
    ans = 0

    for a in sorted(A):
        if a == 1:
            if ctr[a] == 1:
                ans = 1
            break

        if ctr[a] == 1:
            for v in memo:
                if a % v == 0:
                    break
            else:
                ans += 1

        memo.append(a)
        dp.add(a)

    print(ans)

    
if __name__ == "__main__":
    main()
    

### FIXED CODE ###

from collections import Counter

N, *A = map(int, open(0).read().split())

m = max(A) + 1
ok = [True] * m
ctr = Counter(A)
ans = 0
for a in sorted(A):
    if ok[a] and ctr[a] == 1:
        ans += 1
        
    for j in range(2 * a, m, a):
        ok[j] = False
            
print(ans)
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

from bisect import bisect_left, bisect_right

n, d, a = map(int, input().split())
x = []
xh =dict()
for _ in range(n):
    xi, hi = map(int, input().split())
    x.append(xi)
    xh[xi] = hi
x.sort()

l = 0
ret = 0
while l < n:
    xl = x[l]
    hl = xh[xl]
    l += 1
    if hl <= 0:
        continue
    r = bisect_right(x, xl+2*d)
    k = (hl+(a-1))//a
    ret += k
    for i in range(l, r):
        xh[x[i]] -= k * a
print(ret)

### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

from bisect import bisect_left, bisect_right

n, d, a = map(int, input().split())
x = []
xh = dict()
for _ in range(n):
    xi, hi = map(int, input().split())
    x.append(xi)
    xh[xi] = hi
x.sort()

l = 0
ret = 0
ai = [0] * (n+1)
anow = 0
while l < n:
    xl = x[l]
    hl = xh[xl]
    anow += ai[l]
    hl -= a * anow
    if hl > 0:
        r = bisect_right(x, xl+2*d)
        k = (hl+(a-1))//a
        ret += k
        anow += k
        ai[r] -= k
    l += 1
print(ret)
### BUGGY CODE ###

n,X = map(int,input().split())
x =list(map(int,input().split()))
x.append(X)
x.sort()
a = []
for i in range(n):
  a.append(x[i+1]-x[i])
  
g = []
h = min(a)
for i in range(1,h+1):
  if h%i == 0:
    g.append(i)
    
gcd = []
for i in g:
  if all(a[j]%i == 0 for j in range(n)):
    gcd.append(i)
    
print(max(gcd))
    
  
  




### FIXED CODE ###

n,X = map(int,input().split())
x =list(map(int,input().split()))
x.append(X)
x.sort()
a = []
for i in range(n):
  a.append(x[i+1]-x[i])
  
h = min(a)
gcd = 1
for i in range(h,0,-1):
  if h%i == 0:
    if all(a[j]%i == 0 for j in range(n)):
      gcd = i
      break
      
print(gcd)
### BUGGY CODE ###

# fp = open("DPL_1_D-in11.txt")
# inlist = list(map(int, fp.read().splitlines()))
n = int(input())
A = []
dp = [0 for _  in range(n)]
dp[0] = 1
for i in range(n):
    num = int(input())
    A.append(num)
    dpmax = 0
    for j in range(i):
        if A[j] < num and dp[j] > dpmax:
            dpmax = dp[j]
    dp[i] = max(dpmax + 1, 1)    
print(max(dp))

### FIXED CODE ###

import bisect
n = int(input())
A = []
for i in range(n):
    num  = int(input())
    if A == []:
        A.append(num)
    elif num > A[-1]:
        A.append(num)
    else:
        j = bisect.bisect_left(A, num)
        A[j] = num
print(len(A))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

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

for i in range(1,N+1):
    w,v=map(int,input().split())

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

print(dp[N][W])

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

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

for i in range(1,N+1):
    w,v=map(int,input().split())

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

print(dp[N][W])
### BUGGY CODE ###

from fractions import gcd
from sys import exit

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

l_gcd_list = [0]
r_gcd_list = [0]
for i in range(N):
    l_gcd_list.append(gcd(l_gcd_list[i], A[i]))
    r_gcd_list.insert(0, gcd(r_gcd_list[0], A[-(i+1)]))
# print(l_gcd_list)
# print(r_gcd_list)

result = 0
for i, _ in enumerate(A):
    result = max(result, gcd(l_gcd_list[i], r_gcd_list[i+1]))

print(result)


### FIXED CODE ###

from fractions import gcd
from sys import exit

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

l_gcd_list = [0]
r_gcd_list = [0]
for i in range(N):
    l_gcd_list.append(gcd(l_gcd_list[i], A[i]))
    r_gcd_list.append(gcd(r_gcd_list[i], A[-(i+1)]))
r_gcd_list = r_gcd_list[::-1]
# print(l_gcd_list)
# print(r_gcd_list)

results = []
for i in range(N):
    results.append(gcd(l_gcd_list[i], r_gcd_list[i+1]))

print(max(results))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b.reverse()
for i in b:
    print(i,end=" ")

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = []
if n % 2 == 0:
    for i in range(n//2):
        b.append(a[n-2*i-1])
    for i in range(n//2):
        b.append(a[2*i])
else:
    for i in range((n-1)//2):
        b.append(a[n-2-2*i])
    for i in range((n-1)//2):
        b.append(a[i*2])
    b.append(a[n-1])
    b.reverse()
for i in b:
    print(i,end=" ")
### BUGGY CODE ###

a=input()
b=input()
c=input()

X=[a,b,c]
LEN=[len(a),len(b),len(c)]

MF=[[[1]*2001 for j in range(3)] for i in range(3)]

for i in range(3):
    for j in range(3):
        if i==j:
            continue
        for k in range(2001):
            for l in range(LEN[j]):
                if k+l>=LEN[i]:
                    break
                if X[i][k+l]!="?" and X[j][l]!="?" and X[i][k+l]!=X[j][l]:
                    MF[i][j][k]=0
                    break

ANS=1000000
for i in range(3):
    for j in range(3):
        if i==j:
            continue
        for k in range(2001):
            if MF[i][j][k]==1:
                for l in range(2001):
                    if ANS<=max(LEN[i],LEN[j]+k,LEN[3-i-j]+k+l):
                        break
                    if MF[j][3-i-j][l]==1 and (k+l>2000 or MF[i][3-i-j][k+l]==1):
                        ANS=max(LEN[i],LEN[j]+k,LEN[3-i-j]+k+l)

print(ANS)


### FIXED CODE ###

a=input()
b=input()
c=input()

X=[a,b,c]
LEN=[len(a),len(b),len(c)]

MF=[[[1]*2001 for j in range(3)] for i in range(3)]

for i in range(3):
    for j in range(3):
        if i==j:
            continue
        for k in range(2001):
            for l in range(LEN[j]):
                if k+l>=LEN[i]:
                    break
                if X[i][k+l]!="?" and X[j][l]!="?" and X[i][k+l]!=X[j][l]:
                    MF[i][j][k]=0
                    break

ANS=1000000
for i in range(3):
    for j in range(3):
        if i==j:
            continue
        for k in range(2001):
            if MF[i][j][k]==1:
                for l in range(2001):
                    if ANS<=max(LEN[i],LEN[j]+k,LEN[3-i-j]+k+l):
                        break
                    if MF[j][3-i-j][l]==1 and (k+l>2000 or MF[i][3-i-j][k+l]==1):
                        ANS=max(LEN[i],LEN[j]+k,LEN[3-i-j]+k+l)

print(ANS)
### BUGGY CODE ###

d = input()
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

res = r*g*b
for i in range(len(s)-2):
    for j in range(i,len(s)-1):
        k = 2 * j - i
        if k < len(s) and s[i] != s[k] and s[i] != s[j] and s[j] != s[k]:
            res -= 1
print(res)


### FIXED CODE ###

d = input()
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

res = r*g*b
for i in range(len(s)-2):
    for j in range(i,len(s)-1):
        k = 2 * j - i
        if k < len(s) and s[i] != s[k] and s[i] != s[j] and s[j] != s[k]:
            res -= 1
print(res)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
Adic={}
for i in range(N):
  if A[i] not in Adic:
    Adic[A[i]] = 1
  else:
    Adic[A[i]] += 1
Aset = set(A)
if 1 in Aset: #1がある場合
  if Adic[1] == 1:
    print(1)
  else:
    print(0)
  exit()
ans = 0
for j in range(N):
  Flag = True
  temp = A[j]
  i = 2
  if Adic[temp] >= 2:
    continue
  while i*i <= temp:
    #print(i,temp)
    if temp%i == 0:
      #print(i,temp//i,temp)
      if i in Aset or temp//i in Aset:
        Flag = False
        #print(i,temp//i,"X")
        break
    if temp%2 !=0: #奇数の時
      if i == 2:
        i = 3
      else:
        i += 2
    else:
      i += 1
  if not Flag:
    continue
  ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
MAX = max(A) #Aの中の最大値
Adic={}
for i in range(N):
  if A[i] not in Adic:
    Adic[A[i]] = 1
  else:
    Adic[A[i]] += 1
Aset = set(A)
if 1 in Aset: #1がある場合
  if Adic[1] == 1:
    print(1)
  else:
    print(0)
  exit()
ans = 0
for j in range(N):
  temp = A[j]
  if Adic[temp] >= 2: #同じ数が複数ある場合には削除
    if temp in Aset:
      Aset.remove(temp)
  fmax = MAX//temp
  #print(fmax,temp)
  for i in range(2,fmax+10): #fmaxまで見る
    now = temp*i
    if now in Aset:
      Aset.remove(now)
#print(Aset)
print(len(Aset))
### BUGGY CODE ###

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

    from functools import reduce
    ans = reduce(lambda lhs, rhs: lhs * rhs, A)

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

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

def resolve():
    _ = input()
    an = sorted(map(int, input().split()), reverse=True)

    ans = 1
    if an[-1] == 0:
        ans = 0
    else:
        for a in an:
            ans *= a
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)
    
if __name__ == '__main__':
    resolve()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

H,W,K=map(int,input().split())
sy,sx,gy,gx=map(int,input().split())
st=sx+sy*(W+2)
gl=gx+gy*(W+2)
c=['@']*(W+2)
for i in range(H):
    c.extend(['@']+list(input())+['@'])
c.extend(['@']*(W+2))
que=deque()
dist=[INF]*(W+2)*(H+2)
que.append(st)
dist[st]=0
d=(-1,1,W+2,-(W+2))
while que:
    v=que.popleft()
    tmp_dist=dist[v]+1
    for k in range(4):
        nv=v
        for _ in range(K):
            nv+=+d[k]
            if c[nv]=='.':
                if dist[nv]>tmp_dist:
                    dist[nv]=tmp_dist
                    que.append(nv)
            else:
                break
print(dist[gl] if dist[gl]!=INF else -1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

H,W,K=map(int,input().split())
sy,sx,gy,gx=map(int,input().split())
st=sx+sy*(W+2)
gl=gx+gy*(W+2)
c=['@']*(W+2)
for i in range(H):
    c.extend(['@']+list(input())+['@'])
c.extend(['@']*(W+2))
que=deque()
dist=[INF]*(W+2)*(H+2)
que.append(st)
dist[st]=0
d=(-1,1,W+2,-(W+2))
while que:
    v=que.popleft()
    for k in range(4):
        nv=v
        for _ in range(K):
            nv+=+d[k]
            if c[nv]=='.' and dist[nv]>dist[v]:
                if dist[nv]==INF:
                    dist[nv]=dist[v]+1
                    que.append(nv)
            else:
                break
print(dist[gl] if dist[gl]!=INF else -1)
### BUGGY CODE ###

import itertools

n = int(input())
s = list(input())
ans = 0

for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            flag1 = 0
            flag2 = 0
            flag3 = 0
            for m in range(n):
                if flag1 == 0:
                    if int(s[m]) == i:
                        flag1 = 1
                elif flag2 == 0:
                    if int(s[m]) == j:
                        flag2 = 1
                elif flag3 == 0:
                    if int(s[m]) == k:
                        flag3 = 1
                        ans += 1
                        break
                    
print(ans)


### FIXED CODE ###

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

li = [[] for _ in range(10)]

for i in range(n):
    t = int(s[i])
    li[t].append(i)

a = 0
b = 0
c = 0
cnt = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      b = 0
      a = 0
      
      if len(li[i]) > 0:
        a = li[i][0]
          
        for d in li[j]:
            if d > a:
                b = d
                break
        else:
            break
        
        for e in li[k]:
            if e > b:
                cnt += 1
                break
        

print(cnt)