Harryxun/stf_run huggingface dataset:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()

l = {i: 0 for i in range(13)}

for d in D:
    l[d] += 1

possible_lists = [[]]

for k, v in l.items():
    if v > 2:
        possible_lists = [0]
        break
    elif v > 1:
        new = [[0]] + [pl + [k, 24-k] for pl in possible_lists]
        # new = [pl + [k, k] for pl in possible_lists] + [pl + [24-k, 24-k] for pl in possible_lists] + [pl + [k, 24-k] for pl in possible_lists]
        possible_lists = new
    elif v > 0:
        new = [pl + [k] for pl in possible_lists] + [pl + [24-k] for pl in possible_lists]
        possible_lists = new

Max = -1
for pl in possible_lists:
    Min = 13
    pl.sort()
    for i in range(len(pl)):
        if i == 0:
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        elif i == len(pl)-1:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        else:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
    Max = max(Min, Max)

print(Max)


### FIXED CODE ###

import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()

l = {i: 0 for i in range(13)}

for d in D:
    l[d] += 1

possible_lists = [[]]

for k, v in l.items():
    if v > 2:
        possible_lists = [[0]]
        break
    elif v > 1:
        new = [[0]] + [pl + [k, 24-k] for pl in possible_lists]
        # new = [pl + [k, k] for pl in possible_lists] + [pl + [24-k, 24-k] for pl in possible_lists] + [pl + [k, 24-k] for pl in possible_lists]
        possible_lists = new
    elif v > 0:
        new = [pl + [k] for pl in possible_lists] + [pl + [24-k] for pl in possible_lists]
        possible_lists = new

Max = -1
for pl in possible_lists:
    Min = 13
    pl.sort()
    for i in range(len(pl)):
        if i == 0:
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        elif i == len(pl)-1:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        else:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
    Max = max(Min, Max)

print(Max)
import sys
input = sys.stdin.readline
def main():
    T = input().rstrip()
    T_list = []
    for i, c in enumerate(T):
        if i == 0:
            T_list.append(c)
            continue
        if c == "?":
            if T_list[i-1] == "P":
                T_list.append("D")
            elif T_list[i-1] == "D":
                T_list.append("P")
            continue
        T_list.append(c)
    print("".join(T_list))
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    T = list(input().rstrip())
    ans = ["D" if c == "?" else c for c in T]
    print("".join(ans))
if __name__ == "__main__":
    main()
#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

a = clocks[0]
for i in range(1, N):
  a = gcd(a, clocks[i])
  b = a * clocks[i] / a

print(b)

### FIXED CODE ###

#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

b = clocks[0]
for i in range(1, N):
  a = gcd(b, clocks[i])
  b = b * clocks[i] // a

print(b)
s=input()+'T'
x,y=map(int,input().split())
if 'T' in s:
  pos=s.index('T')
  x-=pos
  s=s[pos+1:]
arr=s.split('T')
xarr=[]
yarr=[]
for i in range(len(arr)):
  l=len(arr[i])
  if l==0:
    continue
  if i%2==0:
    yarr.append(l)
  else:
    xarr.append(l)
xarr=sorted(xarr)
yarr=sorted(yarr)
xsums=[0]
for val in xarr:
  xsums.append(xsums[-1]+val)
ysums=[0]
for val in yarr:
  ysums.append(ysums[-1]+val)
xmax=xarr[-1]
ymax=yarr[-1]
xsum=xsums[-1]
ysum=ysums[-1]
x+=xsum
y+=ysum
if x%2==1 or y%2==1:
  print('No')
else:
  xdp=[0]*(xsum+xmax+5)
  xdp[0]=1
  for j in range(len(xarr)):
    val=xarr[j]
    for i in range(xsums[j]+val+1,-1,-1):
      if i-val<0:
        break
      if xdp[i-val]==1:
        xdp[i]=1
  ydp=[0]*(ysum+ymax+5)
  ydp[0]=1
  for j in range(len(yarr)):
    val=yarr[j]
    for i in range(ysums[j]+val+1,-1,-1):
      if i-val<0:
        break
      if ydp[i-val]==1:
        ydp[i]=1
  if xdp[x//2]==0:
    print('No')
  else:
    if ydp[y//2]==0:
      print('No')
    else:
      print('Yes')

### FIXED CODE ###

s=input()+'T'
x,y=map(int,input().split())
if 'T' in s:
  pos=s.index('T')
  x-=pos
  s=s[pos+1:]
arr=s.split('T')
xarr=[]
yarr=[]
for i in range(len(arr)):
  l=len(arr[i])
  if l==0:
    continue
  if i%2==0:
    yarr.append(l)
  else:
    xarr.append(l)
x+=sum(xarr)
y+=sum(yarr)
if x%2==1 or y%2==1:
  print('No')
else:
  #DP for xarr,yarr
  xdp=[0]*8005
  xdp[0]=1
  for val in xarr:
    for i in range(8004,-1,-1):
      if i-val<0:
        break
      if xdp[i-val]==1:
        xdp[i]=1
  ydp=[0]*8005
  ydp[0]=1
  for val in yarr:
    for i in range(8004,-1,-1):
      if i-val<0:
        break
      if ydp[i-val]==1:
        ydp[i]=1
  if xdp[x//2]==0:
    print('No')
  else:
    if ydp[y//2]==0:
      print('No')
    else:
      print('Yes')
b = input()
if b = "A":
  print("T")
elif b = "T":
  print("A")
elif b = "C":
  print("D")
else:
  print("C")

### FIXED CODE ###

b = input()
if b == "A":
  print("T")
elif b == "T":
  print("A")
elif b == "C":
  print("G")
else:
  print("C")
from collections import defaultdict as dd
from collections import deque
d=dd(list)
q=deque([])

N,M=map(int, input().split())
for _ in range(M):
    f=0
    i,j=map(int, input().split())
    if i>j:
        i,j=j,i
    d[i].append(j)
chk=[0]*N
chk[0]=1
temp=1
a=0
while a<N:
    for i in range(len(d[temp])):
        chk[d[temp][i]-1]=1
        q.append(d[temp][i])

    if len(q)>0:
        while a<N:
            if chk[a]==0:
                q.append(a+1)
            a+=1
    else:
        temp=q.pop()

ans=0
for i in  range(len(d)):
    ans=max(ans,len(d[i])+1)
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def union(a,b):
    a=find(a)
    b=find(b)
    if a==b:
        return
    
    if rank[a]<rank[b]:
        par[a]=b
        rank[b]+=rank[a]
        rank[a]=rank[b]
    else:
        par[b]=a
        rank[a]+=rank[b]
        rank[b]=rank[a]

    return

def chk(a,b):
    if par[a]==par[b]:
        print('Yes')
    else:
        print('No')

    return

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

par=(list(range(N+1)))
rank=[1]*(N+1)

for _ in range(M):
    A,B=map(int, input().split())
    union(A,B)

print(max(rank))
MOD = 1000000007

def fractorial(n):
    ans = 1
    for i in range(n):
        ans *= (i+1)
        ans = ans % MOD    
    return ans


N, M = list(map(int, input().split(" ")))

if abs(N - M) > 1:
    print("%d"%(0))
elif (N - M) == 0:
    print ("%d"%(2*((factorial(N))*(factorial(M)))%MOD))
else :
    print ("%d"%(((factorial(N))*(factorial(M)))%MOD))

### FIXED CODE ###

MOD = 1000000007

dp=[0 for _ in range(100001)]
dp[0]=1

for i in range(1, 100001):
    dp[i] = dp[i-1]*i%MOD


N, M = list(map(int, input().split(" ")))

if abs(N - M) > 1:
    print("%d"%(0))
elif (N - M) == 0:
    print ("%d"%(2*((dp[N])*(dp[M]))%MOD))
else :
    print ("%d"%(((dp[N])*(dp[M]))%MOD))
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
count = 1
for i in L
  D = D + i
  if X < D:
    break
  count += 1
print(count)

### FIXED CODE ###

N, X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
count = 1
for i in L:
  D += i
  if X < D:
    break
  count += 1
print(count)
n=int(input())
d=''.join([''.join(input().split())for i in range(n//19+1)])
i=0
while True:
 if d.find(str(i))==-1:
  print(i)
  exit() 
 i+=1

### FIXED CODE ###

j=''.join
u=input
n=int(u())
d=j(j(u().split())for i in[0]*(n//19+(n%19>0)))
i=0
while 1:
 if d.find(str(i))<0:
  print(i)
  exit() 
 i+=1
c = input()
dic = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y']
ind = dic.index(c)
print(dic[ind+1])

### FIXED CODE ###

c = input()
dic = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ind = dic.index(c)
print(dic[ind+1])
import math
A,B=map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A,B))

### FIXED CODE ###

import fractions
A,B=map(int,input().split())

print((A * B) // fractions.gcd(A, B))
import sys

a = int(raw_input())
b = int(raw_input())

print a * b, 2 * a + 2 * b

### FIXED CODE ###

import sys

(a, b) = map(int, input().split())

print (a * b, (a + b) * 2)
import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
fft = np.fft.rfft
ifft = np.fft.irfft
mod = 998244353

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

dp = np.zeros(U+10, dtype=np.int64)
dp[0] = 1
for a in A:
    newDP = dp.copy() * 2
    if a <= S:
        newDP[a:] += dp[:-a]
        newDP %= mod
    dp = newDP

print(dp[S])

### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
fft = np.fft.rfft
ifft = np.fft.irfft
mod = 998244353

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

dp = np.zeros(U+10, dtype=np.int64)
dp[0] = 1
for a in A:
    newDP = dp.copy() * 2
    newDP[a:] += dp[:-a]
    newDP %= mod
    dp = newDP

print(dp[S])
import math
N, a, b = map(int, input().strip().split())

if (b-a)%2==0:
    ans=int(math.raound((b-a)/2))
else:
    ans=min(a-1,N-b)+math.ceil((b-a)/2)
print(ans)

### FIXED CODE ###

import math
N, a, b = map(int, input().strip().split())

if (b-a)%2==0:
    ans=(b-a)//2
else:
    ans=min(a-1,N-b)+1+(b-a)//2
print(ans)
n, l = map(int, input().split())
a = range(l. l + n)
print(sum(a) - min(a, key=abs))

### FIXED CODE ###

n, l = map(int, input().split())
a = range(l, l + n)
print(sum(a) - min(a, key=abs))
#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
	r = input()
	
	s = 2*r*3.1415926
	print (s)

if __name__ == '__main__':
	main()


### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
	r = int(input())
	
	s = 2*r*3.1415926
	print (s)

if __name__ == '__main__':
	main()
a, b, c, d = map(int, input().split())
    print(max([a*c, a*d, b*c, b*d]))

### FIXED CODE ###

a, b, c, d = map(int, input().split())
print(max([a*c, a*d, b*c, b*d]))
from itertools import accumulate
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = []
for i in range(N):
  P[i] = (P[i]+1)/2
hope = list(accumulate(P))
 
for j in range(N-K):
  ans.append(hope[j+K]-hope[j])
print(max(ans))

### FIXED CODE ###

N,K = map(int,input().split())
P = list(map(int,input().split()))
for i in range(N):
  P[i] = (P[i]+1)/2
now = sum(P[:K])
ans = now
for j in range(N-K):
  now = now - P[j] + P[j+K]
  ans = max(ans,now)
print(ans)
a, b, c, d, e, f = map(int, input().split())

s = set()
t = set()
for i in range(f//100 + 1):
    for j in range(f//100 + 1):
        if 0 < 100 * (a * i + b * j) <= f :
            s.add(100 *(a * i + b * j))

for k in range(0, f + 1, c):
    for l in range(0, f + 1, d):
        if f >= (k + l):
            t.add(k + l)

mi = 0
ans = [0, 0]
for n in s:
    for m in t:
        if 0 < n + m <= f and mi < (100 * m) /(n + m) <= 100 and m <= n * e // 100:
            mi = (100 * m) / (n + m)
            ans = [str(n + m), str(m)]
print(" ".join(ans))


### FIXED CODE ###

A,B,C,D,E,F = map(int,input().split())
W=set()
for a in range(0,F+1,100*A):
    for b in range(0,F+1-a,100*B):
        W.add(a+b)
S=set()
for c in range(0,F+1,C):
    for d in range(0,F+1,D):
        S.add(c+d)
rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= w*E//100:
            if s/(w+s) > rate:
                rate = s/(w+s)
                ans = w+s, s
print(ans[0],ans[1])
lis 

### FIXED CODE ###

lists = [0,0,0,0,0,0]
for i in range(len(lists)):
        lists[i] = int(input())

if lists[4]-lists[0]<=lists[5]:
        print("Yay!")
else:
        print(":(")
import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
S=input().strip()
M=[input().split() for i in range(Q)]

PLACE=-1

for i in range(Q-1,-1,-1):

    if M[i][0]==S[PLACE+1] and M[i][1]=="L":
        PLACE+=1

    elif PLACE>=0 and M[i][0]==S[PLACE] and M[i][1]=="R":
        PLACE-=1

    if PLACE==N:
        print(0)
        sys.exit()

PLACE2=N

for i in range(Q-1,-1,-1):

    if M[i][0]==S[PLACE2-1] and M[i][1]=="R":
        PLACE2-=1

    elif PLACE2<=N-1 and M[i][0]==S[PLACE2] and M[i][1]=="L":
        PLACE2+=1

    if PLACE==-1:
        print(0)
        sys.exit()

print(max(0,N-(PLACE+1+(N-PLACE2))))

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
S=input().strip()
M=[input().split() for i in range(Q)]

PLACE=-1

for i in range(Q-1,-1,-1):

    if PLACE+1<N and M[i][0]==S[PLACE+1] and M[i][1]=="L":
        PLACE+=1

    elif PLACE>=0 and M[i][0]==S[PLACE] and M[i][1]=="R":
        PLACE-=1

    if PLACE==N:
        print(0)
        sys.exit()

PLACE2=N

for i in range(Q-1,-1,-1):

    if PLACE2-1>=0 and M[i][0]==S[PLACE2-1] and M[i][1]=="R":
        PLACE2-=1

    elif PLACE2<=N-1 and M[i][0]==S[PLACE2] and M[i][1]=="L":
        PLACE2+=1

    if PLACE==-1:
        print(0)
        sys.exit()

print(max(0,N-(PLACE+1+(N-PLACE2))))
N = int(input())

num = [1]
memo = [[ -1 for i in range(12)]for j in range(100000)]
n = 6
while True:
    num.append(n)
    n *= 6
    if n > 100000:
        break
n = 9
while True:
    num.append(n)
    n *= 9
    if n > 100000:
        break
num.sort()

ans = 0
print(num)
#while N > 6:

def DP(n , index):
    if index == 0:
        return  n
    elif n == 0:
        return 0
    min_ = 10000000
    if n < num[index]:
        #print(n,num[index])
        return DP(n,index - 1)
    can = num[index]
    #print(index)
#    print(n//can)
    for i in range(n // can+1):
        min_ = min(min_ , DP(n - i * can,index - 1) + i)
 #       print(i,n,index,DP(n - i*can,index-1))
    
     #   print(min_)
    #print(min_)
    memo[n][index] = min_
    return min_
    
print(DP(N,11))


### FIXED CODE ###

N = int(input())
#num = [1]
#print("a")
"""
#memo = [[ -1 for i in range(12)]for j in range(100000)]
n = 6
while True:
    num.append(n)
    n *= 6
    if n > 100000:
        break
n = 9
while True:
    num.append(n)
    n *= 9
    if n > 100000:
        break
num.sort()

ans = 0
print(num)
#while N > 6:

def DP(n , index):
    if index == 0:
        return  n
    elif n == 0:
        return 0
    min_ = 10000000
    if n < num[index]:
        #print(n,num[index])
        return DP(n,index - 1)
    can = num[index]
    #print(index)
#    print(n//can)
    for i in range(n // can+1):
        min_ = min(min_ , DP(n - i * can,index - 1) + i)
 #       print(i,n,index,DP(n - i*can,index-1))
    
     #   print(min_)
    #print(min_)
    memo[n][index] = min_
    return min_
    
print(DP(N,11))
"""

def ninep(N):
    if N <9:
        return N
    ans = 0
    while N > 0:
        ans += N % 9
        N =N // 9
    return ans


def sixp(N):
    if N <6:
        return N
    ans = 0
    while N > 0:
        ans += N % 6
        N = N // 6
    return ans


ans = 1000000
for i in range(N+1):
    ans = min(ans,ninep(i) + sixp(N - i))
#    print(ninep(i), sixp(N - i),i)

print(ans)
import bisect
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

K, Q = na()
d = na()

u = [0] * (K+1)
for i in range(1, K+1):
    u[i] = u[i - 1] + d[i%K]

import math
# count ax < k (mod p), 0 <= x < n
def countle(l, r, a, n, p):
    if l == r:
        return 0
    s = min(n, int(math.sqrt(n)*3))
    # s = int(math.sqrt(n))
    comb = [a*i % p for i in range(s)]
    comb.sort()

    ret = 0
    b = -a * s % p
    for u in range(n//s):
        # print(u, l, r)
        num = bisect.bisect_left(comb, r) - bisect.bisect_left(comb, l)
        if r < l:
            num += s
        ret += num

        l -= b
        r -= b
        if l < 0:
            l += p
        if r < 0:
            r += p

    if l < r:
        for i in range(n//s*s, n):
            if l <= a * i % p < r:
                ret += 1
    else:
        for i in range(n // s * s, n):
            if a * i % p < r or l <= a * i % p:
                ret += 1
    return ret

# 2 3 5 7
# 0 2 3 5: 3
# 2 4 5 0: 2
# 4 6 0 2: 2
# 6 1 2 4

# a+k < b+k (mod p)
# a < bなら、k in [-a,p-1-b]
# a > bなら、k in [p-a, p-1-b]
# [-a,-1-b][-b, ...]
# a = bなら無
for z in range(Q):
    n, x, m = na()

    # d0 = x
    # ex = 0
    # for i in range(n-1):
    #     d1 = d0 + d[i%K]
    #     if d0 % m < d1 % m:
    #         ex += 1
    #     d0 = d1

    n -= 1

    rem = n%K
    pre = m-1
    x %= m
    ans = 0
    for i in range(rem):
        pre = x
        x = (x + d[i]) % m
        if pre < x:
            ans += 1
    # print(x, n, K, rem, ans)

    l = [0]
    # print(d[rem:] +  d[:rem])
    for v in d[rem:] + d[:rem]:
        l.append((l[-1] + v) % m)
    # print(l)
    turn = 0
    for i in range(len(l)-1):
        # if m-l[i+1] > m-1-l[i]
        if l[i] < l[i+1]:
            turn += 1
    last = m-1-l[-1]
    if x == (x+last+1) % m:
        turn += 1
    # print(ans, turn, last, -x%m, (-x+last+1)%m, l[-1], n//K)
    le = countle(-x%m, (-x+last+1)%m, l[-1], n//K, m)
    # print(le)
    ans += le*turn + (n//K-le)*(turn-1)
    print(ans)
    # assert ans == ex

    # x = turn - (start > last ? 1 : 0)


### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

K, Q = na()
d = na()

for z in range(Q):
    n, x, m = na()

    n -= 1

    rem = n%K
    pre = m-1
    x %= m
    ans = 0
    for i in range(rem):
        pre = x
        x = (x + d[i]) % m
        if pre < x:
            ans += 1

    lpre = 0
    turn = 0
    # print(d[rem:] +  d[:rem])
    for v in d[rem:] + d[:rem]:
        cur = (lpre + v) % m
        if lpre < cur:
            turn += 1
        lpre = cur
    my = turn*m - lpre
    # print(turn, m, my, n//K, x)
    ans += (my * (n//K) + m-x-1) // m - (m-x-1)//m
    print(ans)
def step(n, A):
    memo = A
    def _step(n):
        if memo[n] != -1:
            return memo[n]
        elif n == 1:
            return 1
        elif n == 2:
            if memo[1] == 0:
                return 1
            else:
                return 2
        memo[n] = (_step(n-1) + _step(n-2))%(10**9+7)
        return memo[n]
    return _step(n)

N, M = map(int, input().split())
A = [-1] * (N+1)
for _ in range(M):
    idx = int(input())
    A[idx] = 0
print(step(N, A))

### FIXED CODE ###

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

step = [0] * (N+1)
step[0] = 1
for i in range(1, N+1):
  if A[i]:
    step[i] = step[i-1] + step[i-2]
  else:
    step[i] = 0
print(step[N]%(10**9+7))
def resolve():
    N = int(input())
    A = [int(input()) for n in range(N)]
    B = A.copy()
    B.sort()
    for i in range(N):
        if max(A) > A[i]:
            print(max(A))
        elif max(A) == A[i]:
            if A.count(max(A)) >= 2:
                print(max(A))
            else:
                print(B[-2])
    return

resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    A = [int(input()) for n in range(N)]
    B = A.copy()
    B.sort()
    mx = max(A)
    count = A.count(mx)

    for i in range(N):
        if mx > A[i]:
            print(mx)
        elif mx == A[i]:
            if count >= 2:
                print(mx)
            else:
                print(B[-2])
    return


resolve()
N=int(input())
A=map(int,input().split())
ans=1
for i in range(N):
  ans*=A[i]
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    ans=1
    for i in range(N):
        ans*=A[i]
        if ans >10**18:
            break
    if ans > 10**18:
      print(-1)
    else:
      print(ans)
while 1:
     x, y = map(int, raw_input().split())
     if x == 0 and y == 0:
         break
     else:
         if x > y:
          print "%s %s" % (y,x)
         else:
          print "%s %s" % (x,y)
    

### FIXED CODE ###

while 1:
   x, y = map(int, raw_input().split())
   if x == 0 and y == 0:
      break
   elif x > y:
      print '%s %s' % (y,x)
   else:
      print '%s %s' % (x,y)
a, b, c = sorted(map(int, input().split()))
if a**2 + b**2 == c**2:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

import sys
input()
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
check = [0]*29
for i in range(1, 30):
    check[i-1] = 2**i

for i in A:
    if i % 2 == 0:
        j = 0
        while check[j] <= i:
            if i % check[j] == 0:
                add = check[j]
            else:
                break
                
            j += 1
        ans += j
        
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
check = [0]*30
for i in range(1, 31):
    check[i-1] = 2**i

for i in A:
    if i % 2 == 0:
        j = 0
        while check[j] <= i:
            if i % check[j] == 0:
                add = check[j]
            else:
                break
                
            j += 1
        ans += j
        
print(ans)
c = input()
if "a", "i", "u", "e", "o" in c :
    print("vowel")
else :
    print("consonant")


### FIXED CODE ###


c = input()
if c in "aiueo" :
    print("vowel")
else :
    print("consonant")
import bisect

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

zero_ind=bisect.bisect_left(x,0)
"""
print("max",0,k-zero_ind-1)
print("min",k,n-zero_ind)
print("max",1,k-n+zero_ind-1)
print("min",k,zero_ind+2)
"""
v,w=10**9,10**9
if(n-zero_ind >= k):v=abs(x[zero_ind+k-1])
if(zero_ind >= k):w=abs(x[zero_ind-k])

y=[abs(x[zero_ind+i])+abs(x[zero_ind+i]-x[zero_ind-(k-i)+1]) for i in range(max(0,k-zero_ind-1),min(k,n-zero_ind))]
z=[abs(x[zero_ind-i])+abs(x[zero_ind-i]-x[zero_ind+(k-i)-1]) for i in range(max(1,k-n+zero_ind-1),min(k,zero_ind+2))]

"""
for i in range(k):
    print(abs(x[zero_ind+i]))
    print(x[zero_ind-(k-i)+1])

for i in range(1,k):
    print(abs(x[zero_ind-i]))
    print(x[zero_ind+(k-i)-1])
"""
print(min([v,w]+y+z))
"""
print(y)
print(z)
"""

### FIXED CODE ###

import bisect

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

zero_ind=bisect.bisect_left(x,0)
"""
print("max",0,k-zero_ind-1)
print("min",k,n-zero_ind)
print("max",1,k-n+zero_ind-1)
print("min",k,zero_ind+2)
"""
v,w=10**9,10**9
if(n-zero_ind >= k):v=abs(x[zero_ind+k-1])
if(zero_ind >= k):w=abs(x[zero_ind-k])

y=[10**9]
z=[10**9]

if(zero_ind != 0 and zero_ind != n):
    for i in range(max(0,k-zero_ind-1),min(k,n-zero_ind)):
        if(zero_ind+i<0 or zero_ind+i>=n or zero_ind-(k-i)+1<0 or zero_ind-(k-i)+1>=n):continue
        y.append(abs(x[zero_ind+i])+abs(x[zero_ind+i]-x[zero_ind-(k-i)+1]))
    for i in range(max(1,k-n+zero_ind-1),min(k,zero_ind+2)):
        if(zero_ind-i<0 or zero_ind-i>=n or zero_ind+(k-i)-1<0 or zero_ind+(k-i)-1>=n):continue
        z.append(abs(x[zero_ind-i])+abs(x[zero_ind-i]-x[zero_ind+(k-i)-1]))
    """
    y=[abs(x[zero_ind+i])+abs(x[zero_ind+i]-x[zero_ind-(k-i)+1]) for i in range(max(0,k-zero_ind-1),min(k,n-zero_ind))]
    z=[abs(x[zero_ind-i])+abs(x[zero_ind-i]-x[zero_ind+(k-i)-1]) for i in range(max(1,k-n+zero_ind-1),min(k,zero_ind+2))]
    """

"""
for i in range(k):
    print(abs(x[zero_ind+i]))
    print(x[zero_ind-(k-i)+1])

for i in range(1,k):
    print(abs(x[zero_ind-i]))
    print(x[zero_ind+(k-i)-1])
"""
print(min([v,w]+y+z))
"""
print(y)
print(z)
"""