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

# -*- coding: utf-8 -*-
n, k = map(int,input().split())
p = [int(i) for i in input().split()]

kitai = []
for i in range(n):
    kitai.append((1 + p[i]) / 2)

ans = 0
for i in range(n - k + 1):
    tmp2 = 0
    for j in range(i, i + k):
        tmp2 += kitai[j]
    if ans < tmp2:
        ans = tmp2
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
n, k = map(int,input().split())
p = [int(i) for i in input().split()]

kitai = []
for i in range(n):
    kitai.append((1 + p[i]) / 2)

ans = 0
tmp = 0
for i in range(k):
    tmp += kitai[i]
ans = tmp
for i in range(n - k):
    tmp = tmp - kitai[i] + kitai[i + k]
    if ans < tmp:
        ans = tmp
print(ans)
### BUGGY CODE ###

n, a, b = map(int, input().split())
mod = 10**9+7

### baseを求める
def power_func(a,n,p):
    bi=str(format(n,"b"))#2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res

base = power_func(2, n, mod) - 1

### baseから引く
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

for t in [a, b]:
	base -= comb(n, t, mod)
print(base)

### FIXED CODE ###

def main():
    MOD = 10**9 + 7
    n, a, b = map(int, input().split())
    
    def cmb(n, r):
        if n-r<r:
            r = n-r
        
        X, Y = (1, 1)
        for i in range(r):
            X = X*(n-i)%MOD
            Y = Y*(i+1)%MOD
        return X*pow(Y, MOD-2, MOD)
    
    base = pow(2, n, MOD)-1
    base -= cmb(n, a)
    base -= cmb(n, b)
    base %= MOD
    print(base)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
l=sorted(list(map(int, input().split())))
ans=0
x=[]
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if (l[i]<(l[j]+l[k])and l[j]<(l[i]+l[k]) and l[k]<(l[j]+l[i]) and x.count([l[i],l[j],l[k]])==0):
                x.append([l[i],l[j],l[k]])
                ans+=1


print(ans)

### FIXED CODE ###

def triangles(a): 
    n = len(a) 
    a.sort() 
    count = 0
    for i in range(0,n-2):
        k=i+2
        for j in range(i+1,n): 
            while (k < n and a[i] + a[j] > a[k]): 
                k += 1
            if(k>j): 
                count += k - j - 1
    return count
n=int(input())
a=list(map(int,input().split()))
print(triangles(a))
### BUGGY CODE ###

n,k=map(int,input().split())
d = list(map(int, input().split()))
e = [0]*n

for i in range(len(d)):
    s = (1+d[i])*d[i]/2
    e[i] = s / d[i]

max1 = 0
idx = 0
tmp = 0
for j in range(n):
    if len(e[j:j+k]) < k:
        break
    if j == 0:
        tmp = sum(e[j:j+k])
    else:
        tmp = tmp - e[j-1] + e[j+k-1]
    if max1 < tmp:
        idx = j
        max1 = tmp
print(max1)


### FIXED CODE ###

n,k=map(int,input().split())
d = tuple(map(int, input().split()))
e = [0]*n

for i in range(n):
    s = (1+d[i])*d[i]/2
    e[i] = s / d[i]

max1 = 0
tmp = 0
for j in range(n-k+1):
#    if len(e[j:j+k]) < k:
#        break
    if j == 0:
        tmp = sum(e[j:j+k])
    else:
        tmp = tmp - e[j-1] + e[j+k-1]
    if max1 < tmp:
        max1 = tmp
print(max1)
### BUGGY CODE ###

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

ret = 0
for i in range(2, N - 1) :
    for j in range(1, i) :
        if (i % (i - j) == 0 and 2 * i < N) or (N - 1 - i) % (i - j) != 0 :
            continue
        
        ret = max(ret, sum(s[i::i-j]) + sum(s[i-j:-j-1:i-j]))

print(max(ret, 0))

### FIXED CODE ###

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

ret = 0
for c in range(1, N) :
    k = 1
    tmp = 0
    flag = (N - 1) % c == 0
    while c * k < N - 1 :
        l = c * k
        r = N - 1 - l

        if (flag and r <= l) or r <= c:
            break

        tmp += s[l] + s[r]
        ret = max(ret, tmp)
        k += 1

print(ret)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)
I=lambda:map(int,input().split())
n,m=I()
g=[[]for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a].append(b)
  g[b].append(a)

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      return [j]+dfs(j)
      break
  else:
    return []
z=dfs(1)[::-1]+[1]+dfs(1)
print(len(z))
print(*z)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
I=lambda:map(int,input().split())
n,m=I()
g=[set() for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a].add(b)
  g[b].add(a)

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      l=dfs(j)
      l.append(j)
      return l
      break
  else:
    return []
z=dfs(1)+[1]+dfs(1)[::-1]
print(len(z))
print(*z)
### BUGGY CODE ###

# coding: utf-8

N = int(input())
S = input().strip()

def stone_cnt(idx):
  return S[:idx].count("#") + S[idx:].count(".")

left = 0
right = len(S)

ans = min([stone_cnt(i) for i in range(N+1)])
  

print(ans)

### FIXED CODE ###

# coding: utf-8

N = int(input())
S = input().rstrip('#')

lb = 0
rw = S.count('.')
ans = lb + rw

for i in range(len(S)):
  if S[i] == '.':
    rw -= 1
  else:
    lb += 1
  ans = min(ans, rw + lb)

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

from collections import defaultdict
N,M = map(int,input().split())

l = []
for i in range(N):
    l.append(list(map(int,input().split())))

l.sort(key=lambda x:x[0])
l.sort(key=lambda x:x[1], reverse=True)

d = defaultdict(int)
ind = 0
ans = 0

for i in range(N):
    A,B = l[i]
    if A+ind<=M:
        day = M-A
        while d[day]!=0:
            day-=1
        d[day]=1
        ans+=B
    while d[ind]!=0:
        ind+=1
    if ind>=M:
        break
print(ans)


### FIXED CODE ###

from collections import defaultdict
import heapq

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

l = defaultdict(list)
for i in range(N):
    A,B = map(int,input().split())
    l[A].append(-B)

h = []
ans = 0
for i in range(M):
    for B in l[i+1]:
        heapq.heappush(h,B)
    if len(h)!=0:
        ans += - heapq.heappop(h)
print(ans)
### BUGGY CODE ###

l, r = map(int, input().split())
mod = 2019
mod_min = 2100
for i in range(l,r):
    for j in range(i+1,r+1):

        m = ((i % mod) * (j % mod)) % mod
        
        if m < mod_min:
            mod_min = m

print(mod_min)

### FIXED CODE ###

l, r = map(int, input().split())
mod = 2019
mod_min = 2019


for i in range(l,r):
    for j in range(i+1,r+1):
        m = (i * j) % mod
        if m < mod_min:
            mod_min = m
        if mod_min == 0:
            break
    if mod_min == 0:
        break

print(mod_min)
### BUGGY CODE ###

r, c, k = map(int, input().split())
tizu = [[0 for _ in range(c)] for _ in range(r)]
for _ in range(k):
    rr, cc, v = map(int, input().split())
    tizu[rr - 1][cc - 1] = v
    
dp = [[[0, 0, 0, 0] for _ in range(c)] for _ in range(r)]
dp[0][0][1] = tizu[0][0]

for i in range(r):
    for j in range(c):
        if i != 0:
            dp[i][j][0] = max(dp[i][j][0], max(dp[i - 1][j]))
            dp[i][j][1] = max(dp[i][j][1], max(dp[i - 1][j]) + tizu[i][j])
        if j != 0:
            dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][0])
            dp[i][j][1] = max(dp[i][j][1], dp[i][j - 1][1], dp[i][j - 1][0] + tizu[i][j])
            dp[i][j][2] = max(dp[i][j][2], dp[i][j - 1][2], dp[i][j - 1][1] + tizu[i][j])
            dp[i][j][3] = max(dp[i][j][3], dp[i][j - 1][3], dp[i][j - 1][2] + tizu[i][j])
print(max(dp[-1][-1]))

    

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    
    r, c, k = map(int, input().split())
    tizu = [0 for _ in range(r * c)]
    for _ in range(k):
        rr, cc, v = map(int, input().split())
        tizu[(rr - 1) * c + (cc - 1)] = v
        
    dp = [[0, 0, 0, 0] for _ in range(c)]
    dp[0][1] = tizu[0]
    
    for i in range(r):
        for j in range(c):
            v = tizu[i * c + j]
            if v:
                if i != 0:
                    tmp = max(dp[j])
                    dp[j] = [tmp, tmp + v, 0, 0]
                if j != 0:
                    tmp0 = dp[j - 1][0]
                    tmp1 = dp[j - 1][1]
                    tmp2 = dp[j - 1][2]
                    lst = [max(dp[j][0], tmp0), max(dp[j][1], tmp1, tmp0 + v), max(tmp2, tmp1 + v), max(dp[j - 1][3], tmp2 + v)]
                    dp[j] = lst
            else:
                if i != 0:
                    tmp = max(dp[j])
                    dp[j] = [tmp, 0, 0, 0]
                if j != 0:
                    lst = [max(dp[j][0], dp[j-1][0]), dp[j-1][1], dp[j-1][2], dp[j - 1][3]]
                    dp[j] = lst
    print(max(dp[-1]))
    
main()
### BUGGY CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[]
for i in p:
  t=(1+i)/2
  s.append(t)
lt=[]
for i in range(len(s)-k+1):
  t=sum(s[i:i+k])
  lt.append(t)

print('{:.10f}'.format(max(lt)))

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[]
for i in p:
  t=(1+i)
  s.append(t)
  
t=[0,]
for i in range(n):
  u=t[i]+s[i]
  t.append(u)

ans=0
for i in range(n-k+1):
  ans=max(ans,t[i+k]-t[i])
  

print('{:.10f}'.format(ans/2))
### BUGGY CODE ###

import functools
import operator

pi = functools.partial(functools.reduce, operator.mul)
n = int(input())
a = list(map(int, input().split()))
ans = pi(a)
if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = a[0]
if a[-1] == 0:
    print(0)
else:
    for i in range(1, n):
        ans *= a[i]
        if ans > 10**18:
            ans = -1
            break
    print(ans)
### BUGGY CODE ###

#ひとまず長さだけ持つ，後から表を後ろ向きに見て復元を試みる

s=input()
t=input()

ls=len(s)
lt=len(t)
    
    
#sのi文字目とtのj文字目までで取れる最長部分列の長さ
dp=[[0]*(lt+1) for _ in range(ls+1)]

for i in range(ls):
    for j in range(lt):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

ans=""
i=ls
j=lt
while(i>0 and j>0):
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        i-=1
        j-=1
        ans+=s[i]

print(ans[::-1])

### FIXED CODE ###

#ひとまず長さだけ持つ，後から表を後ろ向きに見て復元を試みる

s=input()
t=input()

ls=len(s)
lt=len(t)
    
    
#sのi文字目とtのj文字目までで取れる最長部分列の長さ
dp=[[0]*(lt+1) for _ in range(ls+1)]

for i in range(ls):
    for j in range(lt):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

ans=""
i=ls
j=lt
while(i>0 and j>0):
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        i-=1
        j-=1
        ans+=s[i]
        


print(ans[::-1])
### BUGGY CODE ###

import numpy as np

H,W = map(int,input().split())
INFTY = 10000
q = []
A = np.array([[(q.append((i,j)) or 0) if c=="#" else INFTY 
               for j,c in enumerate(input())] + [0] for i in range(H)]
             +[[0]*(W+1)])

ans = -1
while q:
    qq = []
    for i,j in q:
        v = A[i,j]+1
        if A[i,j+1] > v:
            A[i,j+1] = v
            qq.append((i,j+1))
        if A[i,j-1] > v:
            A[i,j-1] = v
            qq.append((i,j-1))
        if A[i+1,j] > v:
            A[i+1,j] = v
            qq.append((i+1,j))
        if A[i-1,j] > v:
            A[i-1,j] = A[i,j]+1
            qq.append((i-1,j))
    q = qq
    ans += 1

print(ans)

### FIXED CODE ###

H,W = list(map(int,input().split()))
A = [list(input()) for _ in range(H)]

q = []
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            q.append((i,j))
            A[i][j] = 0
ans = 0
k = 0
while k < len(q):
    i,j = q[k]
    v = A[i][j]
    if i>0 and A[i-1][j]==".":
        A[i-1][j] = v + 1
        q.append((i-1,j))
        ans = max(ans,v+1)
    if i<H-1 and A[i+1][j]==".":
        A[i+1][j] = v + 1
        q.append((i+1,j))
        ans = max(ans,v+1)
    if j>0 and A[i][j-1]==".":
        A[i][j-1] = v + 1
        q.append((i,j-1))
        ans = max(ans,v+1)
    if j<W-1 and A[i][j+1]==".":
        A[i][j+1] = v + 1
        q.append((i,j+1))
        ans = max(ans,v+1)
    k += 1
print(ans)
### BUGGY CODE ###

import sys
import numpy as np

read = sys.stdin.buffer.read

H,W,M = list(map(int, input().split()))

hw = []
w = np.zeros(3*10**5,dtype=np.int64)
h = np.zeros(3*10**5,dtype=np.int64)
 
for i in range(M):
    h_i, w_j = map(int, input().split())
    hw.append([h_i-1, w_j-1])
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 1
mxh_v = h.max()
mxw_v = w.max()
for i in np.where(h==mxh_v)[0]:
    for j in np.where(w==mxw_v)[0]:
        if not([i,j] in hw):
            d = 0
    if d == 0:
        break

print(mxh_v+mxw_v-d)

### FIXED CODE ###

H,W,M = list(map(int, input().split()))

hw = set()
w = [0] * 3*10**5
h = [0] * 3*10**5

for i in range(M):
    h_i, w_j = map(int, input().split())
    hw.add((h_i-1) + (w_j-1)*3*10**6)
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 1
mxh_v = max(h)
mxw_v = max(w)

x = [i for i,j in enumerate(h) if j == mxh_v]
y = [i for i,j in enumerate(w) if j == mxw_v]

for i in x:
    for j in y:
        if not(i + j*3*10**6 in hw):
            print(mxh_v+mxw_v)
            exit()
print(mxh_v+mxw_v-d)
### BUGGY CODE ###

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

total = 0
for i in range(N-1):
  sum_val = sum(A[i+1:N])
  total += A[i]*sum_val
  total %= (10**9+7)
print(total)

### FIXED CODE ###

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

total = 0
sum_val = sum(A[1:N])
for i in range(N-1):
  total += A[i]*sum_val
  total %= (10**9+7)
  sum_val -= A[i+1]
print(total)
### BUGGY CODE ###

from bisect import bisect_right, bisect_left
N = int(input())
L = sorted([int(_) for _ in input().split()])
ans = 0

for n in range(N - 1, -1, -1):
    for m in range(n - 1, -1, -1):
        if abs(N - 1 - bisect_left(L, L[n] + L[m])) > 0:
            #print(n, m)
            ans += bisect_left(L, L[n] + L[m]) - n - 1
            #print("ans", ans)

print(ans)

### FIXED CODE ###

from bisect import bisect_right, bisect_left
N = int(input())
L = [int(_) for _ in input().split()]
ans = 0
L.sort()

for n in range(N - 1, -1, -1):
    for m in range(n - 1, -1, -1):
        ans += bisect_left(L, L[n] + L[m]) - n - 1

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

n, m = map(int, input().split())
lst = list(map(int, input().split()))
s = 0
for i in range(n):
    for j in range(i+1,n+1):
        if sum(lst[i:j]) % m == 0:
            s = s + 1
print(s)

### FIXED CODE ###

n, m = map(int, input().split())
lst = list(map(int, input().split()))
dp = {}
dp[0] = 1
a, s = 0, 0
for i in lst:
    a += i
    a %= m
    if a in dp:
        s += dp[a]
        dp[a] += 1
    else:
        dp[a] = 1
print(s)
### BUGGY CODE ###

a,b,x = map(int, input().split())
print(len([i for i in range(a,b+1) if i%x==0]))

### FIXED CODE ###

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

if x*(b//x)<a:
  print(0)
elif x*(a//x)<a and x*(a//x+1)<a:
  print(0)
else:
  if x*(a//x)<a:
    min_n=a//x+1
  else:
    min_n=a//x
  
  max_n=b//x
  print(max_n-min_n+1)
### BUGGY CODE ###

import itertools
import fractions
n=int(input())
a=list(map(int,input().split()))
ans = 10**18
for i,j in itertools.combinations(a,2):
	ans = min(ans, fractions.gcd(i, j))
print(ans)

### FIXED CODE ###

import itertools
import fractions
n=int(input())
a=list(map(int,input().split()))
a.sort()
mina=a[0]
ans = 10**18
for i in range(n):
	ans = min(ans, fractions.gcd(a[i], mina))
print(ans)
### BUGGY CODE ###

h, n = map(int, input().split())
m = []
for i in range(n):
  m.append(tuple(map(int, input().split())))

b_max = 10**100
dp = [b_max] * (h+1)
dp[0] = 0
for i in range(1, h+1):
  old = list(dp)
  for j in range(n):
    a, b = m[j]
    he = max(0, i - a)
    dp[i] = min(dp[i], b + old[he], dp[he] + b)
print(dp[h])

### FIXED CODE ###

INT_MAX = 10**8
h, n = map(int, input().split())
e = tuple(tuple(map(int, input().split())) for _ in range(n))

dp = [INT_MAX] * (h+1)
dp[0] = 0
for i in range(1, h+1):
  for a, b in e:
    c = dp[max(0, i - a)] + b
    dp[i] = min(dp[i], c)

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

N, X, Y = map(int, input().split())
dist_list = []*N

for i in range(N):
    for j in range(i+1, N):
        a = j - i
        b = abs(i+1 - X) + abs(j+1 -Y) + 1
        if a > b:
            dist_list.append(b)
        else:
            dist_list.append(a)

for k in range(N-1):
    print(dist_list.count(k+1))



### FIXED CODE ###

N, X, Y = map(int, input().split())
dist_list = [0]*N

for i in range(N-1):
    for j in range(i+1, N):
        a = j - i
        b = abs(i+1 - X) + abs(j+1 -Y) + 1
        dist_list[min(a,b)] += 1

for k in range(N-1):
    print(dist_list[k+1])
### BUGGY CODE ###

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

for i in range(N):
  if str(A[i]) in Adic.keys():
    Adic[str(A[i])] += 1
  else:
    Adic[str(A[i])] = 1
else:
  for i in A:
    count = 0
    ADic = Adic.copy()
    ADic[str(i)] -= 1
    for j in ADic.keys():
      count += ADic[j] * (ADic[j] - 1) // 2
    else:
      print(count)

### FIXED CODE ###

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

for i in range(N):
  if str(A[i]) in Adic.keys():
    Adic[str(A[i])] += 1
  else:
    Adic[str(A[i])] = 1
else:
  countDic = {}
  count = 0
  for j in Adic.keys():
    comb = Adic[j] * (Adic[j] - 1) // 2
    count += comb
    countDic[j] = comb
  else:
    for i in A:
      print(count - countDic[str(i)] + ((Adic[str(i)] - 1) * (Adic[str(i)] - 2) // 2))
### BUGGY CODE ###

N , C = map(int, input().split())
ds =[list(map(int, input().split())) for i in range(C)]
cs =[list(map(int, input().split())) for i in range(N)]
c0 = []
c1 = []
c2 = []
for i in range(N):
    for j in range(N):
        if (i+j) % 3 == 0:
            c0.append(cs[i][j])
        elif (i+j) % 3 == 1:
            c1.append(cs[i][j])
        else:
            c2.append(cs[i][j])
d = 10**9
l0 = len(c0)
l1 = len(c1)
l2 = len(c2)
for i in range(C):
    for j in range(C):
        if i == j:
            continue
        for k in range(C):
            if i == k or j == k:
                continue
            d0 = 0
            for l in range(l0):
                if (c0[l]-1) != i:
                    d0 += ds[c0[l]-1][i]
            for h in range(l1):
                if (c1[h]-1) != j:
                    d0 += ds[c1[h]-1][j]
            for l in range(l2):
                if (c2[l]-1) != k:
                    d0 += ds[c2[l]-1][k]
            if d > d0:
                d = d0
print(d)

### FIXED CODE ###

import collections
N , C = map(int, input().split())
ds =[list(map(int, input().split())) for i in range(C)]
cs =[list(map(int, input().split())) for i in range(N)]
c0 = collections.defaultdict(int)
c1 = collections.defaultdict(int)
c2 = collections.defaultdict(int)
for i in range(N):
    for j in range(N):
        if (i+j) % 3 == 0:
            c0[cs[i][j]] += 1
        elif (i+j) % 3 == 1:
            c1[cs[i][j]] += 1
        else:
            c2[cs[i][j]] += 1
            
d = 10**9
for i in range(C):
    for j in range(C):
        if i == j:
            continue
        for k in range(C):
            if i == k or j == k:
                continue
            d0 = 0
            for l in c0:
                d0 += c0[l] * ds[l-1][i]
            for l in c1:
                d0 += c1[l] * ds[l-1][j]
            for l in c2:
                d0 += c2[l] * ds[l-1][k]
            if d > d0:
                d = d0
            
print(d)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
for n in range(N):
    a = [A[m] for m in range(N) if m != n]
    print(max(a))

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
m = max(A)
ans = list(map(str, [m for _ in range(N)]))
if A.count(m) > 1:
    print('\n'.join(ans))
    exit()
AA = A[:]
AA.remove(m)
mm = max(AA)
for n in range(N):
    if A[n] == m:
        ans[n] = str(mm)
        break
print('\n'.join(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
 
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n,q = list(map(int,input().split()))
ball = list(map(int,input().split()))
 
h = Bit(500000+1)
#print(h)
L_most = {}
J = [[] for _ in range(500000+1)]
jump = {}
on = set()

for i,b in enumerate(ball):
  if b not in L_most:
    L_most[b]=i
    h.add(i+1,1)
    on.add(i+1)
  J[b].append(i)
    
for i in range(500000+1):
  for j in range(len(J[i])):
    if j+1<len(J[i]):
      jump[J[i][j]+1] = J[i][j+1]+1
#print(L_most)
#print(jump)
Q = []

 
for _ in range(q):
  l,r = list(map(int,input().split()))
  Q.append((l,r))
  
LOO = list(Q)
Q.sort(key=lambda x:x[0])

c = 1
ans = {}
#print(on)

for l,r in Q:
  for i in range(c,l):
    if i in on:
      on.remove(i)
      h.add(i,-1)
      if i in jump:
        dest = jump[i]
        h.add(dest,1)
        on.add(dest)

  tmp = h.sum(r)- h.sum(l-1)
  ans[(l,r)] = tmp
  c = l

for q in LOO:
  print(ans[q])
  
  
  
  

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n,q = list(map(int,input().split()))
ball = list(map(int,input().split()))
 
h = Bit(n+1)

L = {}
jump = {}
on = set()

for i,b in enumerate(ball):
  if b not in L:
    h.add(i+1,1)
    on.add(i+1)
  if b in L:
    jump[L[b]]=i+1
  L[b] = i+1

Q = []
 
for _ in range(q):
  l,r = list(map(int,input().split()))
  Q.append((l,r))
  
LOO = list(Q)
Q.sort(key=lambda x:x[0])

c = 1
ans = {}

for l,r in Q:
  for i in range(c,l):
    if i in on:
      on.remove(i)
      h.add(i,-1)
      if i in jump:
        dest = jump[i]
        h.add(dest,1)
        on.add(dest)

  tmp = h.sum(r)- h.sum(l-1)
  ans[(l,r)] = tmp
  c = l

p = []
for q in LOO:
  p.append(ans[q])
  
print(*p, sep="\n")
### BUGGY CODE ###

N = int(input())
lis = list(map(int,input().split()))
a = 1
for i in range(N):
  a *= lis[i]
if a <= 10**18:
  print(a)
else:
  print('-1')

### FIXED CODE ###

N = int(input())
lis = list(map(int,input().split()))
a = 1
tf = True
zero = False
for k in range(N):
  if lis[k] == 0:
    zero = True
if not zero:
  for i in range(N):
    a *= lis[i]
    if a > 10**18:
      tf = False
      break
if zero:
  print(0)
else:
  if tf:
    print(a)
  else:
    print('-1')