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

import statistics

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

print(statistics.median(x[1:]))

for i in range(1,n-1):
    print(statistics.median(x[0:i]+x[i+1:]))

print(statistics.median(x[0:n-1]))


### FIXED CODE ###

import statistics

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

high = statistics.median_high(x)
low = statistics.median_low(x)

for i in range(n):
    if x[i]<= low:
        print(high)
    else:
        print(low)
### BUGGY CODE ###

def main():
    n=int(input())
    xyp=[list(map(int,input().split()))for _ in range(n)]
    ans=[10**20]*(n+1)
    ans[0]=sum(min(abs(x),abs(y))*p for x,y,p in xyp)
    ans[-1]=0
    xx=[[]]
    yy=[[]]
    for bitt in range(1,1<<n):
        xs=[(10**20,0)]
        ys=[(10**20,0)]
        for i in range(n):
            if bitt&(1<<i):
                xs.append((xyp[i][0],i))
                ys.append((xyp[i][1],i))
        xs.sort()
        ys.sort()
        xx.append(xs)
        yy.append(ys)
    for trit in range(1,3**n):
        z=0
        xbit=0
        ybit=0
        for i in range(n):
            if trit%3==0:z+=1
            if trit%3==1:xbit+=1<<i
            if trit%3==2:ybit+=1<<i
            trit//=3
        if z==0:continue
        anss=[min(abs(x),abs(y))*p for x,y,p in xyp]
        if xbit:
            xs=xx[xbit]
            i=0
            notx=[1]*n
            for x,j in xx[-xbit-1][:-1]:
                while abs(xs[i][0]-x)>abs(xs[i+1][0]-x):i+=1
                anss[j]=min(anss[j],abs(xs[i][0]-x)*xyp[j][2])
                notx[j]=0
            for j in range(n):
                if notx[j]:anss[j]=0
        if ybit:
            ys=yy[ybit]
            i=0
            noty=[1]*n
            for y,j in yy[-ybit-1][:-1]:
                while abs(ys[i][0]-y)>abs(ys[i+1][0]-y):i+=1
                anss[j]=min(anss[j],abs(ys[i][0]-y)*xyp[j][2])
                noty[j]=0
            for j in range(n):
                if noty[j]:anss[j]=0
        ans[n-z]=min(ans[n-z],sum(anss))
    print(*ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

n=int(input())
xyp=[list(map(int,input().split())) for i in range(n)]
cost=[10**20]*(1<<n)
cost[0]=0
for bitt in range(1,1<<n):
  xx=[]
  yy=[]
  pp=[]
  m=0
  for i in range(n):
    x,y,p=xyp[i]
    if (1<<i)&bitt:
      xx.append(x)
      yy.append(y)
      pp.append(p)
      m+=1
  for i in range(m):
    sx=xx[i]
    anss=0
    for x,y,p in zip(xx,yy,pp):
      anss+=min(abs(y),abs(x),abs(sx-x))*p
    cost[bitt]=min(cost[bitt],anss)
  for j in range(m):
    sy=yy[j]
    anss=0
    for x,y,p in zip(xx,yy,pp):
      anss+=min(abs(y),abs(x),abs(sy-y))*p
    cost[bitt]=min(cost[bitt],anss)
dp=[sum(min(abs(xyp[i][0]),abs(xyp[i][1]))*xyp[i][2] for i in range(n) if (1<<i)&j) for j in range(1<<n)]
print(dp[-1])
for j in range(n):
  for i in range((1<<n)-1,0,-1):
    x=i
    while x>=0:
      x&=i
      dp[i]=min(dp[i],dp[i-x]+cost[x])
      x-=1
  print(dp[-1])
### BUGGY CODE ###

n = int(input())
s = list(input())
R = s.count("R")
G = s.count("G")
B = s.count("B")
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        k = 2*j - i
        if k <= n - 1:
            k = 2*j-i
            if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
                cnt += 1
print(R*G*B - cnt)

### FIXED CODE ###

n = int(input())
s = input()
R = s.count("R")
G = s.count("G")
B = s.count("B")
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        if j - i <= n - 1 - j:
            if s[i] != s[j] and s[j] != s[2*j - i] and s[i] != s[2*j - i]:
                cnt += 1
print(R*G*B - cnt)
### BUGGY CODE ###

def main():
  S=input()
  N=int(input())
  cnt=0
  for i in range(N):
    tmp=[i for i in input().split() ]
    if tmp[0]=='1':
      cnt+=1
    else:
      if (cnt+int(tmp[1]))%2==1:
        S=tmp[2]+S
        
      else:
        S=S+tmp[2]
        
  if cnt%2!=0:
    S=''.join(list(reversed(S)))

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


### FIXED CODE ###

def main():
  S=input()
  N=int(input())
  cnt=0
  f=''
  b=''
  for i in range(N):
    tmp=[i for i in input().split() ]
    if tmp[0]=='1':
      cnt+=1
    else:
      if (cnt+int(tmp[1]))%2==1:
        f=tmp[2]+f
        
      else:
        b=b+tmp[2]
  ans=f+S+b        
  if cnt%2!=0:
    ans=''.join(list(reversed(ans)))

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

from itertools import islice
x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)
e = sorted((ci + di for ci in c for di in islice(d, k)), reverse=True)
print(*islice(e, k), sep='\n')

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)[:k]
e = sorted((ci + di for ci in c for di in d), reverse=True)[:k]
print(*e)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
check = [i for i in range(1, N+1)]
t = [[0 for i in range(9)] for _ in range(9)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in check:
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                t[i-1][l-1] += 1
for i in range(1, N+1):
    if str(i)[-1] == "0":
        continue
    elif len(str(i)) == 1:
        ans += t[i-1][i-1]
    else:
        ans += t[int(str(i)[-1])-1][int(str(i)[0])-1]
print(ans)


### FIXED CODE ###

N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)
### BUGGY CODE ###

from sys import stdin
import bisect
n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
a.sort()
sum = 0
for i in range(m):
    a[n-1] = a[n-1] // 2
    a.sort()
for i in range(n):
    sum += a[i]
print(sum)


### FIXED CODE ###

from sys import stdin
import heapq
n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
a = [-1 * x for x in a]
heapq.heapify(a)
for i in range(m):
    harf = heapq.heappop(a)
    harf = ((harf*(-1))//2)*(-1)
    heapq.heappush(a,harf)
print(sum(a)*(-1))
### BUGGY CODE ###

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

temp_prev = 0
temp_curr = 0
if b <= 100:
    x = 0.0
else:
    x = min(n, b - 10.0)

while x <= n:
    temp_prev = temp_curr
    temp_curr = int(a * x / b) - a * int(x / b)
    x += 1.0

    if temp_curr < temp_prev:
        break

print(max(temp_curr, temp_prev))

### FIXED CODE ###

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

temp_prev = 0
temp_curr = 0
x = min(n, b-1)

while x <= n:
    temp_prev = temp_curr
    temp_curr = int(a * x / b) - a * int(x / b)
    x += 1.0

    if temp_curr <= temp_prev:
        break

print(max(temp_curr, temp_prev))
### BUGGY CODE ###

def getval():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    return n,k,h 

def main(n,k,h):
    if k>=n-1:
        print(abs(h[-1]-h[0]))
    else:
        dp = [abs(h[i]-h[0]) for i in range(k)]
        for i in range(n):
            if len(dp)<n:
                dp.append(dp[i]+abs(h[i]-h[i+k]))
            for j in range(k-1):
                if i+j+1>=n:
                    break
                dp[i+j+1] = min(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]))
        print(dp[-1])

if __name__=="__main__":
    n,k,h = getval()
    main(n,k,h)


### FIXED CODE ###

def getval():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    return n,k,h 

def main(n,k,h):
    if k>=n-1:
        print(abs(h[-1]-h[0]))
    else:
        dp = [abs(h[i]-h[0]) for i in range(k)]
        for i in range(n):
            if len(dp)<n:
                dp.append(dp[i]+abs(h[i]-h[i+k]))
            for j in range(k-1):
                if i+j+1>=n:
                    break
                dp[i+j+1] = min(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]))
        print(dp[-1])

if __name__=="__main__":
    n,k,h = getval()
    main(n,k,h)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

H,W = map(int , input().split())
sh,sw = map(int , input().split())
eh,ew = map(int , input().split())
mv_a_pts = [[-1,0],[1,0],[0,-1],[0,1]]
mv_b_pts = []
for h in range(-2,3,1):
  for w in range(-2,3,1):
    if h != 0 or w != 0:
      mv_b_pts.append([h,w])
maze = [input() for _ in range(H)]
warp_cnts = [[None]*(W) for j in range(H)]

def mv_a(h,w):
  mv_b_tgs.append([h,w])
  warp_cnts[h][w] = cnt
  for vh,vw in mv_a_pts:
    tgh = h + vh
    tgw = w + vw
    if 0 <= tgh <= H-1 and 0 <= tgw <= W-1 :
      if warp_cnts[tgh][tgw] is None and maze[tgh][tgw] != "#":
        mv_a(tgh,tgw)

def mv_b(h,w):
  for vh,vw in mv_b_pts:
    tgh = h + vh
    tgw = w + vw
    if 0 <= tgh <= H-1 and 0 <= tgw <= W-1 :
      if warp_cnts[tgh][tgw] is None and maze[tgh][tgw] != "#":
        mv_a_tgs.append([tgh,tgw])
        

mv_b_tgs=[]
mv_a_tgs = [[sh-1,sw-1]]
cnt = 0
while len(mv_a_tgs)>0:
  while len(mv_a_tgs):
    tg = mv_a_tgs.pop()
    mv_a(tg[0],tg[1])
  while len(mv_b_tgs):
    wp = mv_b_tgs.pop()
    mv_b(wp[0],wp[1])
  cnt+=1
print(-1 if warp_cnts[eh-1][ew-1] is None else warp_cnts[eh-1][ew-1])

### FIXED CODE ###

from collections import deque
 
 
walk = [(1, 0), (-1, 0), (0, 1), (0, -1)]
warp = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
        (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),
        (0, -2), (0, -1), (0, 1), (0, 2),
        (1, -2), (1, -1), (1, 0), (1, 1), (1, 2),
        (2, -2), (2, -1), (2, 0), (2, 1), (2, 2),]
 
 
def get_warped(walked, map_):
    warped = deque()
    while walked:
        h, w = walked.popleft()
        for i, j in warp:
            h2 = h + i
            w2 = w + j
            if -1 < h2 < H and -1 < w2 < W and map_[h2][w2] == '.':
                warped.append((h2, w2))
                map_[h2][w2] = map_[h][w] + 1
    return warped, map_
 
 
def get_walked(candidate, map_):
    walked = deque()
    while candidate:
        h, w = candidate.popleft()
        walked.append((h, w))
        for i, j in walk:
            h2 = h + i
            w2 = w + j
            if -1 < h2 < H and -1 < w2 < W and map_[h2][w2] == '.':
                candidate.append((h2, w2))
                map_[h2][w2] = map_[h][w]
    return walked, map_
 
H, W = map(int, input().split())
s_h, s_w = [i-1 for i in map(int, input().split())]
d_h, d_w = [i-1 for i in map(int, input().split())]
map_ = [list(input()) for i in range(H)]
 
candidate = deque([(s_h, s_w)])
map_[s_h][s_w] = 0
 
while candidate:
    walked, map_ = get_walked(candidate, map_)
    candidate, map_ = get_warped(walked, map_)
 
for h in range(H):
    for w in range(W):
        if map_[h][w] == '.':
            map_[h][w] = -1
 
print(map_[d_h][d_w])
### BUGGY CODE ###

import bisect
# N, M = 10, 3
# ARR = [1, 8, 5, 7, 100, 4, 52, 33, 13, 5]
# BRR = [
#     [3, 10],
#     [4, 30],
#     [1, 4]
# ]
N,M = map(int,input().split())
ARR = list(map(int,input().split()))
BRR = []
for i in range(M):
    BRR.append(list(map(int,input().split())))

def calculate(n, m, arr, brr):
    brr = sorted(brr, key=lambda x: -x[1])
    arr = sorted(arr)
    result = 0
    sIndex = 0
    for br in brr:
        kIndex = min(bisect.bisect_left(arr[sIndex:len(arr)],br[1]),br[0])
        if kIndex == 0:
            break
        result = result + kIndex*br[1]
        sIndex = sIndex + kIndex

    result = result + sum(arr[sIndex:len(arr)])

    print(result)

calculate(N, M, ARR, BRR)

### FIXED CODE ###

# N, M = 10, 3
# ARR = [1, 8, 5, 7, 100, 4, 52, 33, 13, 5]
# BRR = [
#     [3, 10],
#     [4, 30],
#     [1, 4]
# ]


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

def calculate(n, m, arr, brr):
    raw = []
    for ar in arr:
        raw.append([ar, 1])
    for br in brr:
        raw.append([br[1], br[0]])

    raw = sorted(raw,key=lambda x:-x[0])
    # print(raw)

    offset = 0
    sum = 0
    for ra in raw:
        if offset + ra[1] <= n:
            sum = sum + ra[1] * ra[0]
            offset = offset + ra[1]
        else:
            sum = sum + (n - offset) * ra[0]
            offset = n
            break
    print(sum)

calculate(N, M, ARR, BRR)
### BUGGY CODE ###

import itertools

n = int(input())
L = map(int, input().split())

def is_rectangle(a,b,c):
    if a + b <= c:
      return False
    if b + c <= a:
      return False
    if c + a <= b:
        return False
    else:
        return True

x = [is_rectangle(a,b,c) for a, b, c in itertools.combinations(L, r=3)]


print(sum(x))

### FIXED CODE ###

#提出 #8086687

import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for b in range(n):
  for a in range(b):
    ans += bisect.bisect_left(l,l[a]+l[b])-(b+1)
print(ans)
### BUGGY CODE ###

import sys

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

H, W = lr()
A = [lr() for _ in range(H)]
B = [lr() for _ in range(H)]
diff = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        diff[i][j] = abs(A[i][j] - B[i][j])

dp = [[[False] * 12000 for j in range(W)] for i in range(H)]
dp[0][0][diff[0][0]] = True
for i in range(H):
    for j in range(W):
        for k in range(12000):
            if dp[i][j][k]:
                if i < H-1:
                    dp[i+1][j][abs(k+diff[i+1][j])] = True
                    dp[i+1][j][abs(k-diff[i+1][j])] = True
                if j < W-1:
                    dp[i][j+1][abs(k+diff[i][j+1])] = True
                    dp[i][j+1][abs(k-diff[i][j+1])] = True

for k in range(100):
    if dp[H-1][W-1][k] == True:
        answer = k
        break

print(answer)


### FIXED CODE ###

import sys
import numpy as np

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

H, W = lr()
A = [lr() for _ in range(H)]
B = [lr() for _ in range(H)]
diff = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        diff[i][j] = abs(A[i][j] - B[i][j])

X = (H+W) * 80
L = X + X + 1 #真ん中を0とする、最後に-X
dp = [[None] * W for _ in range(H)]
dp[0][0] = np.zeros(L, np.bool)
dp[0][0][X+diff[0][0]] = 1; dp[0][0][X-diff[0][0]] = 1 #非負整数のみでも良い
for h in range(H):
    for w, di in enumerate(diff[h]):
        if h == 0 and w == 0:
            continue
        x = np.zeros(L, np.bool)
        if h > 0:
            x[di:] |= dp[h-1][w][:L-di]
            x[:L-di] |= dp[h-1][w][di:]
        if w > 0:
            x[di:] |= dp[h][w-1][:L-di]
            x[:L-di] |= dp[h][w-1][di:]
        dp[h][w] = x

dp = dp[-1][-1]
possible = np.where(dp)[0] - X
answer = np.abs(possible).min()
print(answer)
# 07
### BUGGY CODE ###

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

flag = True
for i in range(10**18):
    if k == 0:
        break
    if a == b and b == c:
        break
    A = a
    B = b
    C = c
    a = B + C
    b = A + C
    c = A + B
    if i == k - 1:
        break
    if a - b > 10**18 or a-b < -10**18:
        flag = False
        break
if flag:
    print(a - b)
else:
    print('Unfair')


### FIXED CODE ###

a, b, c, k = map(int, input().split())
x = a - b
if x > 10**18:
    print('Unfair')
elif k % 2 == 0:
    print(x)
else:
    print(-x)
### BUGGY CODE ###

x = int(input())

p = []
for i in range(1, 10):
  p.append(i)

ans = 0
index = x

while 1:
    if index <= len(p):
      break
    index -= len(p)
    for i in p:
      for j in range(-1, 2):
          d = i % 10 + j
          if d < 0 or d > 9:
              continue

          nx = i * 10 + d
          p.append(nx)

ans = p[x - 1]
print(ans)



### FIXED CODE ###

x = int(input())

p = [None for _ in range(100)]

p[1] = (1,2,3,4,5,6,7,8,9)

def getByKeta(n):
    for i in p[n-1]:
        for j in range(-1, 2):
          d = i % 10 + j
          if d < 0 or d > 9:
              continue

          yield i * 10 + d

for i in range(2, 11):
    p[i] = tuple(getByKeta(i))

ans = 0
for i in range(1, 11):
    if x <= len(p[i]):
        ans = p[i][x-1]
        break
    x -= len(p[i])
print(ans)

# p = []
# for i in range(1, 10):
#   p.append(i)

# ans = 0
# index = x

# while 1:
#     if index <= len(p):
#       break
#     index -= len(p)
#     for i in p:
#       for j in range(-1, 2):
#           d = i % 10 + j
#           if d < 0 or d > 9:
#               continue

#           nx = i * 10 + d
#           p.append(nx)

# print(p)
# print(len(p))
# ans = p[1]
# print(ans)
### BUGGY CODE ###

import collections

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

c=c.most_common()

for i in a:
    ans=0
    for j in c:
        t1=j[0]
        t2=j[1]
        
        if t1==i:
            t2-=1
        
        ans+=(t2*(t2-1))//2
    else:
        print(ans)

### FIXED CODE ###

import collections
 
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
all_ans=0

for i,j in c.items():
    all_ans+=(j*(j-1))//2

for k in a:
    print(all_ans-((c[k]*(c[k]-1))//2)+(((c[k]-1)*(c[k]-2))//2))
### BUGGY CODE ###

import numpy as np


def solve(s):
    MOD = 10 ** 9 + 7
    dp = np.zeros(13, dtype=np.int64)
    idx = [0] * 13
    for i in range(13):
        idx[i * 10 % 13] = i
    dp[0] = 1
    for c in s:
        ndp = np.zeros(13, dtype=np.int64)
        if c == '?':
            tdp = dp[idx]
            for i in range(10):
                ndp += np.roll(tdp, i)
            ndp %= MOD
        else:
            i = int(c)
            ndp = np.roll(dp[idx], i)
        dp = ndp
    return dp[5]


s = input()
print(solve(s))


### FIXED CODE ###

import numpy as np


def solve(s):
    MOD = 10 ** 9 + 7
    dp = np.zeros(13, dtype=np.int64)
    dp[0] = 1
    idx = np.zeros(13, dtype=np.int8)
    for i in range(13):
        idx[i * 10 % 13] = i
    window = np.ones(10, dtype=np.int8)
    for c in s:
        if c == '?':
            tdp = dp[idx]
            ndp = np.concatenate([tdp[4:], tdp])
            dp = np.convolve(ndp, window, mode='valid') % MOD
        else:
            dp = np.roll(dp[idx], int(c))
    return dp[5]


s = input()
print(solve(s))
### BUGGY CODE ###

S = input()
k = int(input())

N = len(S)
A = []

for i in range(N):
    for j in range(1, N+1-i):
        A.append(S[i:i+j])

A = list(set(A))
A.sort()

print(A[k-1])


### FIXED CODE ###

import string


def make_string(string, flag_matched=False, N=5000):
    if string[-1] == 'z':
        string = string[:-1]
        flag_matched = False
    if flag_matched == False or len(string) == N:
        string = string[:-1] + chr(ord(string[-1] )+1)
    else:
        string += 'a'
    return(string)


S = input()
k = int(input())

N = len(S)
if N <= 50:

    A = []

    for i in range(N):
        for j in range(1, N+1-i):
            A.append(S[i:i+j])

    A = list(set(A))
    A.sort()

    print(A[k-1])

else:

    c = 0
    q = 'a'

    while True:
        if q in S:
            c += 1
            if c == k:
                break
            else:
                q  = make_string(q, True, N)
        else:
            q  = make_string(q, False, N)

    print(q)
### BUGGY CODE ###

import itertools

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    for x in range(N):
        tmp = [y for idx, y in enumerate(A) if idx != x]
        result = list(filter(lambda t: t[0] == t[1], itertools.combinations(tmp, 2)))
        print(len(result))


### FIXED CODE ###

import sys
import itertools
from collections import Counter
sys.setrecursionlimit(10**8)
if __name__ == "__main__":
    N = int(input())
    A = input().split()
    counter = Counter(A)
    result = 0
    for c in counter.values():
        result += c*(c-1)//2
    for a in A:
        k = counter[a]
        print(result - k*(k-1)//2 + (k-1)*(k-2)//2)
### BUGGY CODE ###

def main():
    from operator import mul
    from functools import reduce
    n, *a = map(int, open(0).read().split())
    b = reduce(mul, a)
    if b > 10 ** 18:
        print(-1)
    else:
        print(b)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, *a = map(int, open(0).read().split())
    ans = 1
    if a.count(0):
        print(0)
        exit()
    for i in a:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            break
    else:
        print(ans)


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

n = int(input())

conbi = 0

strings = []
for i in range(n):
  
  notinstr = 1
  s = input()
  l = [0] * 27 #27こめがかぶった回数
  for j in s:
    l[ord(j)-ord('a')] += 1
  
  for string in strings:
    f = 0
    for j in range(26):
      if l[j] != string[j]:
        f = 1
        break
    
    if(f == 0):
      string[26] += 1
      #print(string[26])
      conbi += string[26]
      notinstrs = 0
      break
  
  if notinstr == 1:
    strings.append(l)
  
print(conbi)

### FIXED CODE ###

n = int(input())

conbi = 0

strings = {}
for i in range(n):
  
  notinstr = 1
  s = input()
  l = 0
  for c in s:
    l += 10**(ord(c)-ord('a'))
  #print(l)
  
  if l in strings:
    conbi += strings[l]
    strings[l] += 1
    
  else:
    strings[l] = 1
  
print(conbi)
### BUGGY CODE ###

from collections import deque

N=int(input())
a=[[] for v in range(N+1)]
d=[[-1 for v in range(N+1)] for u in range(N+1)]
for e in range(1,N):
    u,v,w=map(int,input().split())
    a[u].append(v);a[v].append(u)
    d[u][v]=d[v][u]=w

c=[None for v in range(N+1)] # color

# print(a)
# print(d)

q=deque()
q.append(1);c[1]=True #;d1[1]=0 
while q:
    u=q.popleft()
    for v in a[u]:
        if c[v] is None:
            c[v]=c[u] if d[u][v]%2==0 else not c[u]
            q.append(v)

for ci in c[1:]:
    print(1 if ci else 0)

### FIXED CODE ###

from collections import deque

N=int(input())
a=[set() for v in range(N)] # 0-initial
for e in range(1,N):
    u,v,w=map(int,input().split())
    a[u-1].add((v-1,w))
    a[v-1].add((u-1,w))

d=[-1 for v in range(N)] # distance from 0

q=deque()
q.append(0);d[0]=0
while q:
    u=q.popleft()
    for v,w in a[u]:
        if d[v]==-1:
            d[v]=d[u]+w
            q.append(v)

for di in d:
    print(di%2)
### BUGGY CODE ###

n, m = list(map(int, input().split()))
ab = []
for i in range(m):
    x, y = [int(j) for j in input().split()]
    ab.append((x, y))

aida = []
for i in range(m):
    if ab[i][1] == n:
        aida.append(ab[i][0])

for i in range(m):
    if ab[i][0] == 1 and ab[i][1] in aida:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")


### FIXED CODE ###

n, m = list(map(int, input().split()))
# a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
to = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)
# print(to)
for i in range(len(to[0])):
    if n-1 in to[to[0][i]]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
### BUGGY CODE ###

N, K = map(int, input().split())
P_list = [i for i in map(int, input().split())]

def func(a):
	a_list = [i/a for i in range(1, a+1)]
	return sum(a_list)

P_exp = list(map(func, P_list))

A_list = []
sum_K = 0
for i in range(N-K+1):
	for j in range(K):
		sum_K += P_exp[i+j]

	A_list.append(sum_K)
	sum_K = 0

print(max(A_list))
#print(A_list)


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
P_exp = np.array([0] + [(1+i)/2 for i in map(int, input().split())])
E_sum = np.cumsum(P_exp)

print((E_sum[K:]-E_sum[:-K]).max())