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

import numpy as np
def solve(n, x, y):
    def dist(i, j):
        return min(abs(x[i]-x[j]), abs(y[i]-y[j]))
    que = []
    for v in [x, y]:
        p = np.argsort(v)
        for i in range(n-1):
            u, v = p[i], p[i+1]
            que.append((u, v, dist(u, v)))
    parent = {i: i for i in range(n)}
    def find(i):
        if parent[i] == i:
            return i
        else:
            return find(parent[i])
    ans = 0
    for u, v, d in sorted(que, key=lambda _: _[2]):
        u = find(u)
        v = find(v)
        if u != v:
            ans += d
            if u > v:
                u, v = v, u
            parent[u] = v
    return ans

n = int(input())
x = np.zeros(n, dtype=int)
y = np.zeros(n, dtype=int)
for i in range(n):
    x[i], y[i] = map(int, input().split())
print(solve(n, x, y))

### FIXED CODE ###

import numpy as np

def solve(n, x, y):
    def dist(i, j):
        return min(abs(x[i]-x[j]), abs(y[i]-y[j]))
    que = []
    for p in map(np.argsort, [x, y]):
        for i in range(n-1):
            u, v = p[i], p[i+1]
            que.append((u, v, dist(u, v)))
    parent = [i for i in range(n)]
    def find(i):
        if parent[i] == i:
            return i
        else:
            j = find(parent[i])
            parent[i] = j
            return j
    ans = 0
    for u, v, d in sorted(que, key=lambda _: _[2]):
        u = find(u)
        v = find(v)
        if u != v:
            ans += d
            if u > v:
                u, v = v, u
            parent[v] = u
    return ans

n = int(input())
x = np.zeros(n, dtype=int)
y = np.zeros(n, dtype=int)
for i in range(n):
    x[i], y[i] = map(int, input().split())
print(solve(n, x, y))
### BUGGY CODE ###

N,K = map(int,input().split())
p = [list(map(int,input().split())) for i in range(N)]
used = [False for i in range(N)]
def dfs(p,K,d=0,ans=[[],[]],s=float('inf')):
    if K==d:
        s = abs(max(ans[0])-min(ans[0]))*abs(max(ans[1])-min(ans[1]))
        return s
    for i in range(len(p)):
        if used[i]:
            continue
        used[i] = True
        ans[0].append(p[i][0])
        ans[1].append(p[i][1])
        s = min(s,dfs(p,K,d+1,ans))
        del ans[0][d]
        del ans[1][d]
        used[i] = False
    return s
print(dfs(p,K))


### FIXED CODE ###

N,K = map(int,input().split())
X,Y = [],[]
p = []
for i in range(N):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)
    p.append([x,y])
X.sort(),Y.sort()
ans = abs(X[N-1]-X[0])*abs(Y[N-1]-Y[0])
for xi in range(N):
    for xj in range(xi+1,N):
        for yi in range(N):
            for yj in range(yi+1,N):
                lx,rx = X[xi],X[xj]
                dy,uy = Y[yi],Y[yj]
                num = 0
                for x,y in p:
                    if lx<=x and x<=rx and dy<=y and y<=uy:
                        num += 1
                if K==num:
                    ans = min(abs(rx-lx)*abs(uy-dy),ans)
print(ans)
### BUGGY CODE ###

#ABC051b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

k, s = map(int, input().split())
c = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            #print(x, y, z)
            if (x + y + z == s):
                c += 1
print(c)

### FIXED CODE ###

#ABC051b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

k, s = map(int, input().split())
c = 0
for x in range(k + 1):
    for y in range(k + 1):
        if (0 <= s - x - y <= k):
            c += 1
print(c)
### BUGGY CODE ###

from collections import Counter

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

d = Counter(As)

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    if B in d:
        d[C] += d[B]
        d[B] = 0
    
    print(sum(k*v for k, v in d.items()))

### FIXED CODE ###

from collections import Counter

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

d = Counter(As)
S = sum(k*v for k, v in d.items())
Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    if B in d:
        S += d[B] * (C-B)
        d[C] += d[B]
        d[B] = 0
    print(S)
### BUGGY CODE ###

import math

a, b = map(float, input().split())
times = 0
a = int(a)
if a == 0 or b == 0:
    print(0)
else:
    for k in range(0, a):
        times += b
    new_times = math.floor(times)
    print(new_times)

### FIXED CODE ###

a,b=input().split()
a=int(a)
b=float(b)*1000
b=int(b)
print(int((a*b)//1000))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
a = 0
for i in range(1,N+1) :
    ans = A.count(i)
    print(ans)
    a += ans
    if a >= len(A) :
        for j in range(N-i) :
            print('0')
        exit()

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
C = [0] * N
for i in range(len(A)) :
    x = A[i]
    C[x-1] += 1
for i in range(N) :
    print(C[i])
### BUGGY CODE ###

import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

ans = 0
for i in range(N):
    while A[i] >= 2:
        A[i] -= 2
        ans += 1
    if i + 1 < N and A[i] >= 1 and A[i + 1] >= 1:
        A[i] -= 1
        A[i+1] -= 1
        ans += 1
print(ans)



### FIXED CODE ###

import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

ans = 0
for i in range(N):
    while A[i] >= 2:
        ans += A[i] // 2
        A[i] %= 2
    if i + 1 < N and A[i] >= 1 and A[i + 1] >= 1:
        A[i] -= 1
        A[i+1] -= 1
        ans += 1
print(ans)
### BUGGY CODE ###

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

lenS = len(s)
#print(lenS)
ans = 0
tempAns = 0
for i in reversed(range(1,lenS//2+1)):
	for j in range(0,n-i+1):
		tempS = s[j:j+i]
		#print(tempS)
		for k in range(1,n-i-j+1):
			if (tempS == s[j+i+k-1:j+2*i+k-1]):
				ans = i
				break
			#print(s[j+i+k-1:j+2*i+k-1], i, j, k)
		if (ans > 0):
			break
	if (ans > 0):
		break
print(ans)


### FIXED CODE ###

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

ans = 0
lenS = 1
for i in range(n):
	tempS = s[i:i+lenS]
	while (tempS in s[i+lenS:]):
		lenS += 1
		tempS = s[i:i+lenS]
		ans += 1

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

import math
n = int(input())
p = list(map(int,input().split()))
# print(p)
op = math.prod(p)
# print(op)
if op > 10**18:
    print(-1)
else:
    print(op)

### FIXED CODE ###

n = int(input())
# for i in range(n):
#     m = int(input())
#     k = k*m
op = 1
p = list(map(int,input().split()))
p.sort()
for i in p:
    op = op*i

    if op > 10**18:
        print(-1)
        exit(0)

print(op)
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
s=[[]for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x: int(x)-1,input().split())
    s[a].append(b)
    s[b].append(a)
sys.setrecursionlimit(300000)
l=[None]*N
l[0]=0
def hu(n,c):
    for i in s[n]:
        if l[i]==None:
            l[i]=c
            hu(i,c+1)
hu(0,1)
t=l.index(max(l))
l=[None]*N
l[t]=0
hu(t,1)
if max(l)%3==1:
    print("Second")
else:
    print("First")

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
s=[[]for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x: int(x)-1,input().split())
    s[a].append(b)
    s[b].append(a)
sys.setrecursionlimit(300000)
l=[None]*N
l[0]=0
def hu(n,c):
    for i in s[n]:
        if l[i]==None:
            l[i]=c
            hu(i,c+1)
hu(0,1)
t=l.index(max(l))
l=[None]*N
l[t]=0
hu(t,1)
if max(l)%3==1:
    print("Second")
else:
    print("First")
### BUGGY CODE ###

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

for i in range(y//10000+1):
    for j in range((y-i*10000)//5000+1):
        for k in range((y-i*10000-j*5000)//1000+1):
            if i+j+k == n and i * 10000 + j * 5000 + k * 1000 == y:
                print(i,j,k)
                exit()

print(-1,-1,-1)


### FIXED CODE ###

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

for i in range(y//10000+1):
    if i > n:
        break
    for j in range((y-i*10000)//5000+1):
        if i + j > n:
            break
        if i * 10000 + j * 5000 + (n-i-j) * 1000 == y:
            print(i,j,n-i-j)
            exit()

print(-1,-1,-1)
### BUGGY CODE ###

S = list(input())
N = len(S)

l = [0] * 2019
index = 0
temp = 0
for i in range(N-1, -1, -1):
    temp += int(S[i]) * pow(10,index)
    l[temp%2019] += 1
    index += 1

ans = l[0]

for i in range(1, 2019):
    ans += l[i] * (l[i]-1) // 2

print(ans)

### FIXED CODE ###

S = list(input())
N = len(S)

l = [0] * 2019
temp = 0
e = 1
for i in range(N-1, -1, -1):
    temp += int(S[i]) * e
    temp %= 2019
    l[temp] += 1
    e *= 10
    e %= 2019

ans = l[0]

for i in range(0, 2019):
    ans += l[i] * (l[i]-1) // 2

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

N = int(input())
S=[]
for i in range(N):
  s=str(input())
  u=''
  t=list(s)
  t.sort()
  for j in range(len(list(t))):
    u +=t[j]
  S +=[u]
count=0
for i in range(N-1):
  for j in range(i+1,N):
    if S[i]==S[j]:
      count +=1
print(count)

### FIXED CODE ###

from collections import defaultdict
N=int(input())
S={}
S_counter = defaultdict(int)
count=0
for i in range(N):
  s="".join(sorted(input()))
  if s in S:
    count += S[s]
    S[s] += 1
  else:
    dict={s:1}
    S.update(dict)
print(count)
### BUGGY CODE ###

s = input()
n = len(s)
cnt = 0
lista = []
for i in range(n):
    inta = int(s[-i - 1:n])
    lista.append(inta)
listb = []
for i in range(n):
    intb = lista[i] % 2019
    listb.append(intb)
for i in listb:
    if i == 0:
        cnt += 1
for i in range(len(listb)):
    for j in range(i + 1, len(listb)):
        if listb[i] == listb[j]:
            cnt += 1
print(cnt)

### FIXED CODE ###

mod = [0]
pw = 1
for c in input()[::-1]:
    # 大きい数字での計算方法
    # a と z が互いに素のとき
    # x == y (mod z)なら
    # ax == ay (mod z)
    # 10000 == 1924 (mod 2019)
    # 100000 == 19240 (mod 2019)
    # 100000 == 1060 (mod 2019) 前のpwを10で掛けた分に2019を割る
    mod.append((int(c) * pw + mod[-1]) % 2019)
    pw = pw * 10 % 2019
from collections import *
# 8646 % 2019 = 余り570
# 282668646 % 2019 = 余り570
# 282668646 - 8646 = 282660000
# 282660000 % 2019 = 140000 余り0
# 余りが同じものをn(n - 1) / 2する
print(sum(v * (v - 1) // 2 for v in Counter(mod).values()))
### BUGGY CODE ###


class Job(object):
    def __init__(self, day, reward):
        self.day = day
        self.reward = reward
        self.is_used = False


class MyJobs(object):
    def __init__(self, num_elements_in_array):
        self.heapm = {}

    def append(self, priority, value):
        if not priority in self.heapm.keys():
            self.heapm[priority] = []
        self.heapm[priority].append(value)

    def get_best(self, priority):
        day = -1
        reward = -1

        for i in range(priority + 1):
            if not (i in self.heapm.keys()):
                continue
            for j in range(len(self.heapm[i])):
                if self.heapm[i][j].is_used:
                    continue
                cur = self.heapm[i][j].reward
                if not (0 > day):
                    best = self.heapm[day][reward].reward
                if (0 > day) or (cur > best):
                    day = i
                    reward = j
        if (0 > day):
            return 0
        self.heapm[day][reward].is_used = True
        return self.heapm[day][reward].reward


(n, m) = map(int, input().split())
jobs = MyJobs(m)
for _ in range(n):
    (a, b) = map(int, input().split())
    jobs.append(a - 1, Job(a - 1, b))

sum = 0
for i in range(m):
    sum += jobs.get_best(i)
print(sum)


### FIXED CODE ###

import heapq

(n, m) = map(int, input().split())
jobs = {}
for _ in range(n):
    (a, b) = map(int, input().split())
    if not a in jobs:
        jobs[a] = []
    jobs[a].append(-b)

heap = []
sum = 0
for i in range(1, m + 1):
    if i in jobs:
        for j in jobs[i]:
            heapq.heappush(heap, j)
    if 0 < len(heap):
        sum -= heapq.heappop(heap)
print(sum)
### BUGGY CODE ###

#入力
HWD = list(map(int, input().split()))
H, W, D = HWD[0], HWD[1],  HWD[2]
field = []
for i in range(H):
    field.append(list(map(int, input().split())))

move_dict = {}
now_point = 1
for number in range(1, H * W - D + 1):
    next_point = now_point + D
    now_flag = False
    next_flag = False
    for field_h in range(H):
        for field_w in range(W):
            if field[field_h][field_w] == now_point:
                now_h = field_h
                now_w = field_w
                now_flag = True
            if field[field_h][field_w] == next_point:
                next_h = field_h
                next_w = field_w
                next_flag = True
        if now_flag and next_flag == True:
            break
            
    move_dict[number] = abs(next_h - now_h) + abs(next_w - now_w)
    now_point += 1
           
Q = int(input())
for test in range(Q):
    target = list(map(int, input().split()))
    count = 0
    step = target[0]
    while not step == target[1]:
        start = step
        count += move_dict[start]
        step = start + D
    print(count)  

### FIXED CODE ###

#入力
HWD = list(map(int, input().split()))
H, W, D = HWD[0], HWD[1],  HWD[2]
field_dict = {}
for h in range(H):
    field = list(map(int, input().split()))
    for w in range(W):
        field_dict[field[w]] = (h, w)

#numberからD動かした時の魔力
move_dict = {}
pre_length = 0
for now_point in range(1, H * W + 1):
    pre_point = now_point - D
    if now_point > D:
        pre_length = move_dict[now_point - D]
        now_h = field_dict[now_point][0]
        now_w = field_dict[now_point][1]
        pre_h = field_dict[pre_point][0]
        pre_w = field_dict[pre_point][1]
        move_dict[now_point] = abs(now_h - pre_h) + abs(now_w - pre_w) + pre_length
    else:
        move_dict[now_point] = 0
           
#試験
Q = int(input())
for test in range(Q):
    target = list(map(int, input().split()))
    count = move_dict[target[1]] - move_dict[target[0]]
    print(count)
### BUGGY CODE ###

lis=[]
n=int(input())
saidai = n + 1
lis += input()
for rida in range(n):
    count=0
    for i in range(n):
        if i < rida and lis[i] == "W":
            count += 1
        elif i > rida and lis[i] == "E":
            count += 1
    if count < saidai:
        saidai = count
print(saidai)

### FIXED CODE ###

lis=[]
n=int(input())
lis += input()
count=0
for i in range(1,n):
    if lis[i]=="E":
        count += 1
saidai = count
for i in range(n-1):
    if lis[i] == "W":
        count += 1
    if lis[i+1] == "E":
        count -= 1
        if saidai > count:
            saidai = count
print(saidai)
### BUGGY CODE ###

n = int(input())
ws = []
for _ in range(n):
    ws.append(input())

nums = []
for w in ws:
    v = [0] * 52
    for c in w:
        if "Z" < c:
            v[ord(c) - ord("a")] += 1
        else:
            v[ord(c) - ord("A") + 26] += 1
    nums.append(v)

ans = 0
found = []
for i in range(n):
    if i in found:
        continue
    r = 0
    for j in range((i+1),n):
        if j in found:
            continue
        v = 1
        for k in range(52):
            if nums[i][k] != nums[j][k]:
                v = 0
                break
        if v != 0:
            r += v
            found.append(j)
    ans += (r + 1) * r // 2

print(ans)


### FIXED CODE ###

n = int(input())
ws = [list(input()) for _ in range(n)]

def sort_l(l):
    l.sort()
    return l
ws = list(map(sort_l, ws))
ws.sort()

i = 0
j = 0
r = 0
ans = 0
while(i<n-1):
    i += 1
    if ws[i] == ws[j]:
        r += 1
    else:
        ans += r * (r+1) // 2
        r = 0
        j = i
ans += r * (r+1) // 2

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

N,*A=map(int,open(0).read().split())
m=1000000000+7
ans=0
for i in range(N):
    for j in range(i+1,N):
        ans+=A[i]*A[j]
ans%=m
print(ans)


### FIXED CODE ###

N,*A=map(int,open(0).read().split())
l=[]
s=0
for a in reversed(A):
    s+=a
    l.append(s)
l.reverse()
m=1000000000+7
ans=0
for i in range(N-1):
    ans+=A[i]*l[i+1]
    ans%=m
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
def main():
    n, q = inputAsIntArr()
    s = input()

    idxes = []
    for i in range(n-1):
        if s[i] != 'A':
            continue
        if s[i+1] == 'C':
            idxes.append(i)
            i += 1

    num_acs = ""
    for i in range(q):
        li, ri = inputAsIntArr()
        num_ac = len([v for v in idxes if li-2 < v < ri-1])
        num_acs += str(num_ac) + "\n"

    print(num_acs.strip())


def inputAsIntArr():
    return [int(i) for i in input().split()]


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, q = map(int, input().split())
    s = input()

    # 累積出現数を格納: 指定される番号が1始まりなのでズラして格納
    p = [0] * (n+1)
    for i in range(n):
        p[i+1] = p[i] + (1 if s[i:i+2] == "AC" else 0)

    for i in range(q):
        l, r = map(int, input().split())
        # 終端(=l-1)から始端-1(=r-1)の累積出現数を引いた数が指定区間内での出現回数
        print(p[r-1] - p[l-1])


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

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

from collections import defaultdict
import bisect


def solve():
    n, m, q = map(int, input().split())
    d = defaultdict(list)
    for i in range(m):
        l, r = map(int, input().split())
        bisect.insort_left(d[l], r)
    table = [[0 for i in range(n + 1)] for j in range(n + 1)]
    dk = [p for p in d.keys()]
    dk.sort()
    for i in range(1, n + 1):
        ri = bisect.bisect_left(dk, i)
        dk = dk[ri:]
        if not dk:
            break
        for j in range(i, n + 1):
            tans = 0
            for k in [p for p in dk if p <= j]:
                tans += bisect.bisect_right(d[k], j)
            table[i][j] = tans
    for i in range(q):
        l, r = map(int, input().split())
        print(table[l][r])


if __name__ == "__main__":
    solve()


### FIXED CODE ###

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

import bisect
import array


def solve():
    n, m, q = map(int, input().split())
    nl = [[0 for i in range(n + 1)] for j in range(n + 1)]
    for e in [input().split() for _ in range(m)]:
        l, r = int(e[0]), int(e[1])
        nl[l][r] += 1
    table = [array.array("i", [0] * (n + 2)) for j in range(n + 2)]
    ran = array.array("i", range(n + 1))
    for i in ran:
        for j in ran:
            table[i][j + 1] = table[i][j] + nl[i][j]

    for i, e in enumerate([input().split() for _ in range(q)]):
        l, r = int(e[0]), int(e[1])
        ans = 0
        for j in range(l, r + 1):
            ans += table[j][r + 1] - table[j][l]
        print(ans)


if __name__ == "__main__":
    solve()
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import heapq

def main():
	h,w=MI()
	ch,cw=MI()
	dh,dw=MI()
	ch+=1
	cw+=1
	dh+=1
	dw+=1

	S=[["#"]*(w+4)]
	S.append(["#"]*(w+4))
	for _ in range(h):
		S.append(["#"]*2+list(RD())+["#"]*2)
	S.append(["#"]*(w+4))
	S.append(["#"]*(w+4))

	#print(S)

	Q=[[0,ch,cw]]
	heapq.heapify(Q)
	S[ch][cw]=0

	#print(Q)

	while Q:
		#print(Q)
		d,x,y=heapq.heappop(Q)

		if S[x][y]<d:
			continue

		for xx,yy in [[0,1],[0,-1],[1,0],[-1,0]]:
			if S[x+xx][y+yy]==".":
				S[x+xx][y+yy]=d
				heapq.heappush(Q,[d,x+xx,y+yy])
			elif S[x+xx][y+yy]=="#":
				continue
			elif S[x+xx][y+yy]>d:
				S[x+xx][y+yy]=d
				heapq.heappush(Q,[d,x+xx,y+yy])

		for xxx in range(-2,3):
			for yyy in range(-2,3):
					if S[x+xxx][y+yyy]==".":
						S[x+xxx][y+yyy]=d+1
						heapq.heappush(Q,[d+1,x+xxx,y+yyy])


	#print(S[2:-2])

	print(-1 if S[dh][dw]=="." else S[dh][dw])


if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque

def main():
	h,w=MI()
	ch,cw=MI()
	dh,dw=MI()
	ch+=1
	cw+=1
	dh+=1
	dw+=1

	S=[["#"]*(w+4)]
	S.append(["#"]*(w+4))
	for _ in range(h):
		S.append(["#"]*2+list(RD())+["#"]*2)
	S.append(["#"]*(w+4))
	S.append(["#"]*(w+4))

	#print(S)

	S[ch][cw]=0
	Q=deque()
	Q.append([0,ch,cw])


	d1=[(0,1),(0,-1),(-1,0),(1,0)]
	d2=[(i,j) for i in range(-2,3) for j in range(-2,3)]

	while Q:
		#print(Q)
		d,x,y=Q.popleft()

		for xx,yy in d1:
			if S[x+xx][y+yy]==".":
				S[x+xx][y+yy]=d
				Q.appendleft([d,x+xx,y+yy])
			elif S[x+xx][y+yy]=="#":
				continue
			elif S[x+xx][y+yy]>d:
				S[x+xx][y+yy]=d
				Q.appendleft([d,x+xx,y+yy])

		for xx,yy in d2:
			if S[x+xx][y+yy]==".":
				S[x+xx][y+yy]=d+1
				Q.append([d+1,x+xx,y+yy])
			elif S[x+xx][y+yy]=="#":
				continue
			elif S[x+xx][y+yy]>d+1:
				S[x+xx][y+yy]=d+1
				Q.appendleft([d+1,x+xx,y+yy])



	#print(S[2:-2])

	print(-1 if S[dh][dw]=="." else S[dh][dw])


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

n = int(input())

def index_Multi(List,liter):
    #Listはリスト本体・literは検索したい文字
    index_L = []
    for i in range(len(List)):
        if liter == List[i]:
            index_L.append(i)
    return index_L

s = []
cnt = [0] * n

for i in range(n):
  tmp = input()
  if tmp not in s:
    s.append(tmp)
  else:
    cnt[s.index(tmp)] += 1
    
_max = 0
for c in cnt:
  if _max < c:
    _max = c


inds = index_Multi(cnt,_max)
results = []
for ind in inds:
  results.append(s[ind])

results.sort()

for result in results:
  print(result)




### FIXED CODE ###

n = int(input())

dic = {}
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

_max = 0
for v in dic.values():
  if _max < v:
    _max = v
dic2 = sorted(dic.items())

for (k,v) in dic2:
  if v == _max:
    print(k)
### BUGGY CODE ###

N = int(input())
A = []
for n in range(N):
    A.append(int(input()))

maximum = max(A)
for i in range(N):
    if A[i] == maximum:
        new = A[:]
        new.pop(i)
        print(max(new))
    else:
        print(maximum)

### FIXED CODE ###

N = int(input())
A = []
for n in range(N):
    A.append(int(input()))

A_sort = sorted(A)
first = A_sort[-1]
second = A_sort[-2]
if first == second:
    for n in range(N):
        print(first)
else:
    for i in range(N):
        if A[i] == first:
            print(second)
        else:
            print(first)
### BUGGY CODE ###

def main():
    N = int(input())
    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))
    ans = 1
    for a in A_list :
        ans = ans * a
    if ans > 10 ** 18 :
        ans = -1

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))
    #print(A_list)
    A_list.sort()
    #print(A_list)
    ans = 1
    for a in A_list :
        ans = ans * a
        if ans == 0 :
            break
        elif ans > 10 ** 18 :
            ans = -1
            break

    print(ans)

if __name__ == '__main__':
    main()