Harryxun/stf_run huggingface dataset:
from math import ceil,sqrt,log,gcd,pi
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())

n=ii()
a=li()
b={}
for i in range(len(a)):
    b[a[i]]=i
a.sort()
x=[]
for i in range(n):
    if i!=b[a[i]]:
        x.append([i,b[a[i]]])
# print(x)
if(len(x)>2):
    print("No")
elif(len(x)==2 and x[0][0]!=x[1][1]):
    print('No')
else:
    print("Yes")

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b={}
for i in range(len(a)):
    b[a[i]]=i
a.sort()
x=[]
for i in range(n):
    if i!=b[a[i]]:
        x.append([i,b[a[i]]])
if(len(x)>2):
    print("NO")
elif(len(x)==2 and x[0][0]!=x[1][1]):
    print('NO')
else:
    print("YES")
def add_node_2_tree_dic(tree_dic, x, y):
    if x not in tree_dic:
        tree_dic[x] = [y]
    else:
        tree_dic[x].append(y)

#   深さ優先探索で行けそう

N = int(input())
tree_dic = {}
for _ in range(N-1):
    a, b = map(int, input().split())
    add_node_2_tree_dic(tree_dic, a, b)
    add_node_2_tree_dic(tree_dic, b, a)

c_lst = list(map(int, input().split()))
c_lst.sort()
ans_lst = [0]*N

def search_next_node_and_add_side_wate(tree_dic, ans, current_node, c_lst, ans_lst):
    tmp_lst = tree_dic[current_node][:]

    for next_node in tmp_lst:
        c = c_lst.pop()
        ans += c
        ans_lst[next_node - 1] = c

        tree_dic[current_node].remove(next_node)    #   今回通った枝を取り払う
        tree_dic[next_node].remove(current_node)

        try:
            if len(tree_dic[current_node]) == 0:
                del tree_dic[current_node]#   探索し終えたノードの削除
            if len(tree_dic[next_node]) == 0:
                del tree_dic[next_node]#   探索し終えたノードの削除
        except:
            return ans


        else:   #   次のノードにつながっている辺があるとき
            ans = search_next_node_and_add_side_wate(tree_dic, ans, next_node, c_lst, ans_lst)


    return ans


ans = 0
current_node = 1
ans_lst[0] = c_lst.pop()
ans = search_next_node_and_add_side_wate(tree_dic, ans, current_node, c_lst, ans_lst)


ans_str = ""
for i in range(N):
    ans_str += str(ans_lst[i])
    if i != N - 1:
        ans_str += " "


print(ans)
print(ans_str)



### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)

def add_node_2_tree_dic(tree_dic, x, y):
    if x not in tree_dic:
        tree_dic[x] = [y]
    else:
        tree_dic[x].append(y)

#   深さ優先探索で行けそう

N = int(input())
tree_dic = {}
for _ in range(N-1):
    a, b = map(int, input().split())
    add_node_2_tree_dic(tree_dic, a, b)
    add_node_2_tree_dic(tree_dic, b, a)

c_lst = list(map(int, input().split()))
c_lst.sort()
ans_lst = [0]*N

def search_next_node_and_add_side_wate(tree_dic, ans, current_node, c_lst, ans_lst):
    next_node_lst = tree_dic[current_node][:]

    for next_node in next_node_lst:
        c = c_lst.pop()
        ans += c
        ans_lst[next_node - 1] = c

        tree_dic[current_node].remove(next_node)    #   今回通った枝を取り払う
        tree_dic[next_node].remove(current_node)

        if len(tree_dic[current_node]) == 0:
            del tree_dic[current_node]#   探索し終えたノードの削除
        if len(tree_dic[next_node]) == 0:
            del tree_dic[next_node]#   探索し終えたノードの削除
        else:   #   次のノードにつながっている辺があるとき
            ans = search_next_node_and_add_side_wate(tree_dic, ans, next_node, c_lst, ans_lst)

    return ans


ans = 0
current_node = 1
ans_lst[0] = c_lst.pop()
ans = search_next_node_and_add_side_wate(tree_dic, ans, current_node, c_lst, ans_lst)


ans_str = ""
for i in range(N):
    ans_str += str(ans_lst[i])
    if i != N - 1:
        ans_str += " "


print(ans)
print(ans_str)
from collections import Counter
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
b = Counter(a_list)
d = b.most_common()[:k]
sum = 0
for i in d:
    sum += i
print(n-i)


### FIXED CODE ###

import collections
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
b = collections.Counter(a_list)
d = b.most_common()[k:]
sum = 0
for i in d:
    sum += i[1]
print(sum)
import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
ans=[]
prev=0
for i in range(1,15):
    ans.append(26**i+prev)
    prev+=26**i
    
n,=I()
p=0
s='abcdefghijklmnopqrstuvwxyz'
f={}
for i in range(1,27):
    f[i]=s[i-1]
for i in range(len(ans)):
    p+=1
    if n<=ans[i]:
        break
an=''
for i in range(p):
    an+=f[n%26]
    n//=26
print(an)
    

### FIXED CODE ###

import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
ans=[]
prev=0
for i in range(1,15):
    ans.append(26**i+prev)
    prev+=26**i
    
n,=I()
p=0
s='abcdefghijklmnopqrstuvwxyz'
f={}
for i in range(1,27):
    f[i]=s[i-1]
for i in range(len(ans)):
    p+=1
    if n<=ans[i]:
        break
an=''
f[0]='z'
for i in range(p):

    an+=f[n%26]
    if n%26:
        n//=26
    else:
        n//=26
        n-=1
    
print(an[::-1])
from collections import Counter
n=input()
strings = []
for i in range(n):
    strings.append(input())
dic = {}
for l in [Counter(s) for s in strings]:
    ll = str(l)
    if ll in dic:
        dic[ll] += 1
    else:
        dic[ll] = 0
res = 0
for k , v in dic.items():
    res += v * (v + 1)/2
print(res)

### FIXED CODE ###

from collections import Counter
n=int(input())
strings = []
for i in range(n):
    strings.append(input())
dic = {}
for string in strings:
    c = Counter(string)
    s = "".join([str(c[l]) for l in "abcdefghijklmnopqrstuvwxyz"])
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 0
res = 0
for k , v in dic.items():
    res += v * (v + 1)/2
print(int(res))
#include <bits/stdc++.h>
using namespace std;

int N;

int main() {
  cin >> N;
  int H[N];
  for (int i = 0; i < N; i++) cin >> H[i];

  int ans = 0;

  for (int i = 0; i < N-1; i++) {
    int tmp = 0;
    for (int j = i; j < N-1;) {
      if (H[j] >= H[j+1]) tmp++;
      else break;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

### FIXED CODE ###

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

ans = 0
cnt = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt
        cnt = 0    
if ans < cnt:
    ans = cnt
print(ans)
N = int(input())
a = list(map(int, input().split()))

even4, even, odd = 0, 0, 0
for i in a:
    if i % 4 == 0:
        even4 += 1
    elif i % 2 == 0:
        even += 1
    else:
        odd += 1

if n % 2 == 0:
    if even4 >= odd:
        print("Yes")
    else:
        print("No")
else:
    if even4 >= odd + 1:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

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

even4, even, odd = 0, 0, 0
for i in a:
    if i % 4 == 0:
        even4 += 1
    elif i % 2 == 0:
        even += 1
    else:
        odd += 1

if N % 2 == 0:
    if even4 >= odd:
        print("Yes")
    else:
        print("No")
else:
    if even4 >= odd - 1:
        print("Yes")
    else:
        print("No")
n,m = map(int,input().split())
a = []
for _ in range(m):
    b = int(input())
    a.append(b)
inf = 1000000007

dp = [0] * (n+1)
dp[0] = 1

if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2,n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= inf
    print(dp)

print(dp[n])

### FIXED CODE ###

n,m = map(int,input().split())
a = set([int(input()) for i in range(m)])
inf = 1000000007

dp = [0] * (n+1)
dp[0] = 1

if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2,n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= inf

print(dp[n])
a=input()
s=a%2
if a==1:
    print(a/2+1)
else:
    print(a/2)

### FIXED CODE ###

import math

a=int(input())
s=a/2
print(math.ceil(s))
N = int(input())
cards = list(map(int, input().split()))
cardsrev = cards.reverse()
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += cardsrev[i]
  else:
    Bob += cardsrev[i]
print(Alice-Bob)

### FIXED CODE ###

N = int(input())
cards = list(map(int, input().split()))
cards.sort(reverse=True) 
print(sum(cards[0::2])-sum(cards[1::2]))
n= int(input())
ninesix = [9**i for i in range(1,6)]+[6**i for i in range(1,7)]
ninesix.sort(reverse=True)

def coin(ns,max_res):
  if max_res < 6:
    return max_res
  count = 0
  remainder = max_res//ns[0]
  c = 1000000000
  if remainder > 0:
    for i in range(1,remainder+1):
      nnss = ns[1:]
      c = min(coin(nnss,max_res-ns[0]*i),c)+i
    count += c
    return count
  else:
    return coin(ns[1:],max_res)
  return count
   
print(coin(ninesix,n))
  

### FIXED CODE ###

N=int(input())
ans=N
for i in range(N+1): 
    cnt=0
    t=i
    while t>0:
        cnt+=t%6
        t//=6
    s=N-i
    while s>0:
        cnt+=s%9
        s//=9
    ans=min(ans,cnt)
print(ans)
n=int(input())
l=[int(input()) for i in range(n)]
ans=0
for i in range(n):
  ans+=(l[i]-l[i]%2)//2
  l[i]%=2
  if l[i]==1
    if i==n-1:break
    ans+=1
    l[i]=0;l[i+1]-=1
print(ans)


### FIXED CODE ###

s=input()
a =["N","S","W","E"]
flag1=0
flag2=0
if a[0] in s and a[1] in s:
  flag1=1
if a[0] not in s and a[1] not in s:
  flag1=1
if a[2] in s and a[3] in s:
  flag2=1
if a[2] not in s and a[3] not in s:
  flag2=1
if flag1+flag2==2:
  print("Yes")
else:
  print("No")
S=input()
if S[2]=S[3] and S[4] = S[5]:
    print ('Yes')
else:
    print('No')

### FIXED CODE ###

S=input()
if S[2] == S[3] and S[4] == S[5]:
    print ('Yes')
else:
    print('No')
import sys
input = sys.stdin.readline
import collections
from collections import defaultdict
import math

n=int(input())
a= [list(map(int, input().split())) for i in range(n)]
b=defaultdict(int)
c=defaultdict(int)
b0=0
c0=0
mod=1000000007
ans=1
cnt=0
for i,j in a:
    i/=math.gcd(i,j)
    j/=math.gcd(i,j)
    if i!=0 and j!=0:
        b[i/j]+=1
        c[j/i]+=1
    elif i==0 and j!=0:
        b0+=1
    elif i!=0 and j==0:
        c0+=1
    else:
        cnt+=1
w=[]
if c0!=0 or b0!=0:
    ans*=pow(2,c0+b0)-((pow(2,c0)-1)*(pow(2,b0)-1))


for k,v in b.items():
    if c[-k]!=0:
        ans*=((pow(2,c[-k]+v)-(pow(2,c[-k])-1)*(pow(2,v)-1)))
        w.append((pow(2,c[-k]+v)-(pow(2,c[-k])-1)*(pow(2,v)-1)))
        ans%=mod
    else:
        ans*=pow(2,v)
        ans%=mod

w=collections.Counter(w)
w=list(w.most_common())

for i,j in w:
    for k in range(j//2):
        ans*=pow(i,mod-2,mod)
ans+=cnt-1
print(int(ans%mod))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import collections
import fractions
from collections import defaultdict
import math

n=int(input())
a= [list(map(int, input().split())) for i in range(n)]
b=defaultdict(int)
c=defaultdict(int)
b0=0
c0=0
mod=1000000007
ans=1
cnt=0
for i,j in a:
    if i!=0 and j!=0:
        x=i
        y=j
        i //= math.gcd(x, y)
        j //= math.gcd(x, y)
        i=abs(i)
        j=abs(j)
        if x*y>0:
            b[(i,j,0)]+=1
            c[(j,i,1)]+=1
        else:
            b[(i,j,1)]+=1
            c[(j,i,0)]+=1

    elif i==0 and j!=0:
        b0+=1
    elif i!=0 and j==0:
        c0+=1
    else:
        cnt+=1
w=[]
if c0!=0 or b0!=0:
    ans*=pow(2,c0+b0)-((pow(2,c0,mod)-1)*(pow(2,b0,mod)-1))

for k,v in b.items():
    if c[k]!=0:
        ans*=(pow(2,c[k]+v,mod)-(pow(2,c[k],mod)-1)*(pow(2,v,mod)-1))
        w.append((pow(2,c[k]+v,mod)-(pow(2,c[k],mod)-1)*(pow(2,v,mod)-1)))
        ans%=mod
    else:
        ans*=pow(2,v,mod)
        ans%=mod

w=collections.Counter(w)
w=list(w.most_common())
for i,j in w:
    for k in range(j//2):
        ans*=pow(i,mod-2,mod)
ans+=cnt-1
print(int(ans%mod))
import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[None]*m
for i in range(m):
    bc[i] = list(map(int, input().split(" ")))
bc.sort(key=lambda x:x[1], reverse=True)
result = 0
for [b,c] in bc:
    if len(a) == 0 or c < a[0]:
        break
    for i in range(b):
        if c < a[i]:
            break
        a[i] = c
    result = result + sum(a[0:b])
    a = a[b:]
print(sum(a)+result)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[None]*m
for i in range(m):
    bc[i] = list(map(int, input().split(" ")))
bc.sort(reverse=True, key=lambda x:x[1])
l=[]
for [b,c] in bc:
    l.extend([c]*b)
    if n < len(l):
        break
for i in range(n):
    if len(l) <= i or l[i] <= a[i]:
        break
    a[i] = l[i]
print(sum(a))
import numpy as np

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
Asorted = sorted(A)[:-(P-1)]

n = len(Asorted)
start=0
end = n
Ap = A[-1]
total = V*M
while start < end -1:
  #print(start, end)
  i = (start+end-1)//2
  Ai = Asorted[i]
  limit = (Ai + M)*(n-i-1) - sum(Asorted[i+1:]) + (i+P)*M
  if limit >= total:
    end = i+1
  else:
    start = i+1
print(np.sum(np.asarray(A)>=Asorted[start]))

### FIXED CODE ###

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

dif = B-A
if dif%2 == 0:
  print(dif//2)
else:
  print(min(A-1, N-B)+1+((dif-1)//2))
n, x = map(int, input().split())
m = [0]*n
for i in range(n):
  	m[i] = int(input())
m.sort()
ans = 0
flag = False
while x > 0:
    for i in range(n):
        if x >= m[i]:
        	x -= m[i]
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
    key = m[0]
    while x > 0:
        if x >= key:
            x -= key
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
print(ans)

### FIXED CODE ###

n, x = map(int, input().split())
m = [0]*n
for i in range(n):
  	m[i] = int(input())
m.sort()
ans = 0
flag = False
while x > 0:
    for i in range(n):
        if x >= m[i]:
            x -= m[i]
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
    key = m[0]
    while x > 0:
        if x >= key:
            x -= key
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
print(ans)
n = int(input())
can = []
x,y,h = map(int,input().split())
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
while len(can) != 1:
  x,y,h = map(int,input().split())
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2]  < abs(x-now[0]) + abs(y-now[1]):
        del now
      else:
        cnt += 1
print(' '.join(list(map(str,can[0]))))

### FIXED CODE ###

n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] > abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  step += 1
print(' '.join(list(map(str,can[0]))))
a,b = map(int.input(),split())
if a <= 9 and b <= 9 :
    print(a*b)
else :
    print(-1)

### FIXED CODE ###

a,b = map(int,input().split())
if a <= 9 and b <= 9 :
    print(a*b)
else :
    print(-1)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0 for _ in range(N)]
b = [0 for _ in range(M)]

a[0] = A[0]
for i in range(1,N):
  a[i] = a[i-1] + A[i]
  
b[0] = B[0]
for j in range(1,M):
  b[j] = b[j-1] + B[j]
  
num = M-1
ans = 0
for k in range(N):
  if a[k] > K:
    break
  while b[num] > K - a[k]:
    num -= 1
  ans = max(ans, k+num+2)
  
print(ans)

### FIXED CODE ###

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

a = [0 for _ in range(N+1)]
b = [0 for _ in range(M+1)]

for i in range(1,N+1):
  a[i] = a[i-1] + A[i-1]
  
for j in range(1,M+1):
  b[j] = b[j-1] + B[j-1]
  
num = M
ans = 0
for k in range(N+1):
  if a[k] > K:
    break
  while b[num] > K - a[k]:
    num -= 1
  ans = max(ans, k+num)
  
print(ans)
n,m=map(int,input().split())
a=[]
for i in range(m):
  a+=list(map(int,input()))

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)


### FIXED CODE ###

n,m=map(int,input().split())
a=[]
for i in range(m):
  a+=list(map(int,input().split()))

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)
import collections
n = int(input())
ls = [input() for i in range(n)]    
c = collections.Counter(ls)
count = c.most_common()[0][1]
ans = []
if c.most_common()[0][1] == 1:
    ls.sort()
    for i in ls:
        print(i)
else:
    c.sort()
    for i in range(len(c)):
        p = c.most_common()
        if p[i][1] == count:
            print(p[i][0])
        else:
            break   

### FIXED CODE ###

import collections
from collections import Counter

n = int(input())
ls = [input() for i in range(n)]    
c = Counter(ls).most_common()

count = c[0][1]
ans = []

for i in range(len(c)):
    if c[i][1] == count:
        ans.append(c[i][0])
    else:
        break   
ans = sorted(ans)
for i in ans:
    print(i)
n,m=map(int,input().split())
st=[]
ch=[]
def mht(ax,ay,bx,by):
  return abs(ax-bx)+abs(ay-by)

for i in range(n):
  st.append(list(map(int,input().split())))
for i in range(m):
  ch.append(list(map(int,input().split())))
  
for i in st:
  ax=i[0]
  ay=i[1]
  mn=100000000
  for (j,k) in zip(ch,range(len(ch))):
    bx=j[0]
    by=j[1]
    mh=mht(ax,ay,bx,by)
    if mh<mn:
      mn=mh
      nm=k
  print(nm)


### FIXED CODE ###

n,m=map(int,input().split())
st=[]
ch=[]
def mht(ax,ay,bx,by):
  return abs(ax-bx)+abs(ay-by)

for i in range(n):
  st.append(list(map(int,input().split())))
for i in range(m):
  ch.append(list(map(int,input().split())))
  
for i in st:
  ax=i[0]
  ay=i[1]
  mn=1000000000
  for (j,k) in zip(ch,range(len(ch))):
    bx=j[0]
    by=j[1]
    mh=mht(ax,ay,bx,by)
    if mh<mn:
      mn=mh
      nm=k
  print(nm+1)
import sys
import math
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
a,b,c = LI()



if c-a-b > and (4*a*b) < ((c-a-b)**2) :
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import sys
import math
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
a,b,c = LI()



if c-a-b > 0 and (4*a*b) < ((c-a-b)**2) :
    print('Yes')
else:
    print('No')
import sys
input = sys.stdin.readline
s = input()
n = len(s)

l_sum = [0]
for i in range(n):
    x = (l_sum[-1] + int(s[n-i-1]) * (10 ** i)) % 2019
    l_sum.append(x)

#print(l_sum)
l_sum.sort()
ans = 0
tmp = 0
cnt = 1
for i in range(1, len(l_sum)):
    if l_sum[i] == tmp:
        cnt += 1
    else:
        ans += cnt * (cnt - 1) // 2
        cnt = 1
        tmp = l_sum[i]

ans += cnt * (cnt - 1) // 2
print(ans)

### FIXED CODE ###

s = list(map(int, input()))
#print(s)
n = len(s)

l_sum = [0]
for i in range(n):
    x = (l_sum[-1] + int(s[n-i-1]) * (pow(10, i, 2019))) % 2019
    l_sum.append(x)

#print(l_sum)
l_sum.sort()
ans = 0
tmp = 0
cnt = 1
for i in range(1, len(l_sum)):
    if l_sum[i] == tmp:
        cnt += 1
    else:
        ans += cnt * (cnt - 1) // 2
        cnt = 1
        tmp = l_sum[i]

ans += cnt * (cnt - 1) // 2
print(ans)
r = 100001
p = [1]*r
p[0] = p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0 for x in range(2*i,r,i)]
prime = []
for i in range(r):
	if p[i]: prime.append(i)
	
while 1:
	n = int(raw_input())
	if n == 0: break
	ans = 0
	i = 0
	while 1:
		s = 0
		j = i
		while 1:
			s += prime[j]
			if s >= n:
				if s == n:
					ans += 1
				else:
					break
			j += 1
		i += 1
		if i > n: break
	print ans

### FIXED CODE ###

r = 100001
p = [1]*r
p[0] = p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0 for x in range(2*i,r,i)]
prime = []
for i in range(r):
	if p[i]: prime.append(i)
	
while 1:
	n = int(raw_input())
	if n == 0: break
	ans = 0
	i = 0
	while 1:
		s = 0
		j = i
		while 1:
			s += prime[j]
			if s >= n:
				if s == n:
					ans += 1
				break
			j += 1
		i += 1
		if prime[i] > n: break
	print ans
x, y, z = map(int, input().split())
print(c, a, b)

### FIXED CODE ###

x, y, z = map(int, input().split())
print(z, x, y)
r_c_str=input().split()
r_c=list(map(lambda i :int(i),r_c_str))
r=r_c[0]
c=r_c[1]
s_str=[input() for i in range(r)]
s_str=[i.split() for i in s_str]
s=[]
for i in s_str:
    s.append(list(map(lambda j :int(j),i)))
for i in range(r):
    s[i].append(sum(s[i]))
s.append([0,0,0,0,0,0])
for i in range(c):
    for j in range(r):
        s[r][i]+=s[j][i]
s[-1][-1]+=sum(s[4])
for i in s:
    print(*i)


### FIXED CODE ###

r_c_str=input().split()
r_c=list(map(lambda i :int(i),r_c_str))
r=r_c[0]
c=r_c[1]
s_str=[input() for i in range(r)]
s_str=[i.split() for i in s_str]
s=[]
for i in s_str:
    s.append(list(map(lambda j :int(j),i)))
for i in range(r):
    s[i].append(sum(s[i]))
s.append([])
for i in range(c+1):
    s[-1].append(0)
for i in range(c):
    for j in range(r):
        s[r][i]+=s[j][i]
s[-1][-1]+=sum(s[r])
for i in s:
    print(*i)
W,H,N=map(int.input().split())
a,b,c,d=0,W,0,H

for i in range(N):
  x,y,A=map(int.input().split())
  if A==1: a=max(a,x)
  if A==2: b=min(b,x)
  if A==3: c=max(c,y)
  if A==4: d=min(d,y)
  
print(max(0,b-a)*max(0,d-c))

### FIXED CODE ###

W,H,N=map(int,input().split())
a,b,c,d=0,W,0,H

for i in range(N):
  x,y,A=map(int,input().split())
  if A==1:
    a=max(a,x)
  if A==2:
    b=min(b,x)
  if A==3:
    c=max(c,y)
  if A==4:
    d=min(d,y)
  
print(max(0,b-a)*max(0,d-c))
import sys
    N,Y = map(int,input().split())
     
    for A in range(N+1)[::-1]:
      for B in range(N-A+1)[::-1]:
        C=N-A-B
        if (10000*A+5000*B+1000*C==Y):
          print(A,B,C)        
          sys.exit()
    print(-1,-1,-1)

### FIXED CODE ###

import sys
N,Y = map(int,input().split())

for A in range(N+1):
  for B in range(N-A+1):
    C=N-A-B
    if (10000*A+5000*B+1000*C==Y):
      print(A,B,C)        
      sys.exit()
print(-1,-1,-1)
s=raw_input()
    n=False
    e=False
    w=False
    ss=False
    for i in xrange(len(s)):
        if s[i]=="N":n=True
        elif s[i]=="E":e=True
        elif s[i]=="W":w=True
        else:ss=True
    if (n and ss) or (e and w):
        print("Yes")
    else:
        if not n and not ss and not e and not w:
            print("Yes")
        else:
            print("No")


### FIXED CODE ###

s=raw_input()
n=False
e=False
w=False
ss=False
for i in xrange(len(s)):
    if s[i]=="N":n=True
    elif s[i]=="E":e=True
    elif s[i]=="W":w=True
    else:ss=True
if (n+ss)%2==0 and (e+w)%2==0:
    print("Yes")
else:
    print("No")
arr=list(map(int,input().split()))
s=0
for i in range(1,4):
  for j in range(2):
    if arr[j]==i:
      s+=(4-i)*100000
if arr[0]==arr[1] and arr[1]=1:
  s+=400000
print(s)
  


### FIXED CODE ###

arr=list(map(int,input().split()))
s=0
for i in range(1,4):
  for j in range(2):
    if arr[j]==i:
      s+=(4-i)*100000
if arr[0]==arr[1] and arr[1]==1:
  s+=400000
print(s)
from math import sqrt, inf

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

    ans = inf
    for i in range(1, int(sqrt(N))+1):
        if N % i == 0:
            tmp = i + (N // i) - 2
            ans = min(ans, tmp)
        
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from math import sqrt

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

    ans = 10**12+1
    for i in range(1, int(sqrt(N))+1):
        if N % i == 0:
            tmp = i + (N // i) - 2
            ans = min(ans, tmp)
        
    print(ans)


if __name__ == "__main__":
    main()
from operator import mul
from functools import reduce

#while True:
N = int(input())
#	if N>=2 and N<=10**5:break

if 2 <= N <= 10**5:
	num = list(map(int, input().split()))
	
#print(num)
ans = reduce(mul,num)
if ans > 10**18:
	print(-1)
else:
	print(ans)

### FIXED CODE ###

A, B = map(int, input().split())
print(A*B)