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

def solve(n):
	ans=0
	for a in range(int(n/4)+1):
		for b in range(a,int(n/3)+1):
			if b>1000:
				break
			for c in range(b,int(n/2)+1):
				if c>1000:
					break
				d=n-(a+b+c)
				if d>=c:
					if a==b==c==d:
						ans+=1#4!/4!
					elif a==b==c or b==c==d:
						ans+=4#4!/3!
					elif a==b and c==d:
						ans+=6#4!/(2!*2!)
					elif (a==b and c!=d) or (b==c) or (a!=b and c==d):
						ans+=12#4!/2!
					else:
						ans+=24#4!
				else:
					break
	return ans 


while True:
	try:
		n=int(input())
		print(solve(n))
	except EOFError:
		break

### FIXED CODE ###

M = 1000
DM = M * 2 + 1
 
def count(n):
    global M
    res = n + 1
    if n > M:
        res -= (n-M) * 2
    return res
 
def solve(n):
    cnt = 0
    for a in range(min(DM, n), -1, -1):
        b = n - a
        if b > DM:
            break
        cnt += count(a) * count(b)
    return cnt
 
while True:
    try:
        l = input()
    except EOFError:
        break
    nm = int(l)
    print(solve(nm))
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
inf = float("inf")
s = [["#"] * (W + 2)]
D = [[inf] * (W + 2)]
white_num = 0
for i in range(H):
    main = list(input())
    white_num += len([e for e in main if e == "."])
    s.append(["#"] + main + ["#"])
    D.append([inf] * (W + 2))
s.append(["#"] * (W + 2))
D.append([inf] * (W + 2))
visited = [[False] * (W + 2) for i in range(H + 2)]


def BFS():  # 幅優先探索
    global D
    D[1][1] = 0
    q = deque()
    q.append((1, 1))
    while len(q) != 0:
        p = q.popleft()
        visited[p[0]][p[1]] = True
        for e in [(p[0] + 1, p[1]), (p[0], p[1] + 1), (p[0] - 1, p[1]), (p[0], p[1] - 1)]:
            if s[e[0]][e[1]] == "." and not visited[e[0]][e[1]]:
                D[e[0]][e[1]] = min(D[p[0]][p[1]] + 1, D[e[0]][e[1]])
                q.append(e)
    return D[H][W]


white_min = BFS() + 1

# for i in range(1, H + 1):
#    print(" ".join(list(map(str, D[i][1:-1]))))

if white_min == inf:
    print(-1)
else:
    print(white_num - white_min)


### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
inf = float("inf")
s = [["#"] * (W + 2)]
D = [[inf] * (W + 2)]
white_num = 0
for i in range(H):
    main = list(input())
    white_num += len([e for e in main if e == "."])
    s.append(["#"] + main + ["#"])
    D.append([inf] * (W + 2))
s.append(["#"] * (W + 2))
D.append([inf] * (W + 2))


def BFS():  # 幅優先探索
    global D
    D[1][1] = 1
    q = deque()
    q.append((1, 1))
    while len(q) != 0:
        p = q.popleft()
        for e in [(p[0] + 1, p[1]), (p[0], p[1] + 1), (p[0] - 1, p[1]), (p[0], p[1] - 1)]:
            if s[e[0]][e[1]] == "." and D[e[0]][e[1]] == inf:
                D[e[0]][e[1]] = D[p[0]][p[1]] + 1
                q.append(e)
                if e == (H, W):
                    return white_num - D[H][W]
    return -1


print(BFS())

# for i in range(1, H + 1):
#    print(" ".join(list(map(str, D[i][1:-1]))))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def EachSumStr(x):
    Len = len(x)
    sum = 0
    for i in range(Len):
        sum += int(x[i])
    #print(sum)

S = str(input())
Slen = len(S) - 1
if (Slen < 4):
    print(0)

else:
    ans = 0
    for i in range(Slen - 3):
        for j in range(i+3, Slen):
            Slice = S[i:j+1]
            if ( int(Slice) != 0 and int(Slice) % 2019 == 0):
                ans += 1
                #print(i, j)
    print(ans)
    #print(Slen)

### FIXED CODE ###

S = input()[::-1]
Surpus = [0] * 2019
Surpus[0] = 1

sum = 0
x = 1
for i in S:
    sum += int(i) * x
    Surpus[sum % 2019] += 1
    x *= 10
    x %= 2019

ans = 0
for i in Surpus:
    ans += i * (i - 1) // 2

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

n = int(input())
boss = list(map(str, input().split()))

for i in range(1, n + 1):
    print(boss.count(str(i)))

### FIXED CODE ###

n = int(input())
boss = list(map(str, input().split()))
ans = [0] * n
for b in boss:
    ans[int(b) - 1] += 1
for a in ans:
    print(a)
### BUGGY CODE ###

a,b=map(int,input().split())
if a<=0 and b>=0:
    print('Zero')
elif a>0 and b>0:
    print('Positive')
elif a<0 and b<0:
    N=1
    for i in range(a,b+1,1):
        N=N*i
    if N>0:
        print("Positive")
    else:
        print("Negative")


### FIXED CODE ###

a,b=map(int,input().split())
if a<=0 and b>=0:
    print('Zero')
elif a>0 and b>0:
    print('Positive')
elif a<0 and b<0:
    if ((-a)-(-b)+1)%2==0:
        print("Positive")
    else:
        print("Negative")
### BUGGY CODE ###

s = list(input())
check = []
# a = []
for i in range(len(s)):
    if i < len(s)-1 and s[i]=='B' and s[i+1]=='C':
        check.append(1)
    else:
        check.append(0)
# print(check)
# for i in range(len(s)):
#     if


count = 0
for i in range(len(s)):
    if s[-i-1] == 'A':
        # a.insert(0, 1)
        tmp = -i-1
        while tmp <= -3 and check[tmp+1]==1:
            # s.pop(tmp)
            # s.insert(tmp+3, 'A')
            check[tmp+1] = 0
            check[tmp] = 1
            # s[tmp+1] = 'C'
            # s[tmp+2] = 'A'
            count += 1
            tmp += 2
print(count)

### FIXED CODE ###

inp = input()
changed_input = inp.replace('BC', 'D')
A_count = 0
total_ans = 0
for st in changed_input:
    if st == 'A':
        A_count += 1
    elif st == 'D':
        total_ans += A_count
    else:
        A_count = 0
print(total_ans)
### BUGGY CODE ###

n = int(input())
a_list = list(map(int, input().split()))
ans_len = 10**6+10
is_ans = [0]*(ans_len)

for a in a_list:
    b = 2*a
    while b < ans_len:
        if is_ans[b] == 0:
            is_ans[b] += 1
        b += a

ans = 0
for a in a_list:
    # print(a, a_list.count(a), is_ans[a])
    if a_list.count(a) == 1:
        ans += (is_ans[a] == 0)
print(ans)


### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
ans_len = 10**6+10
is_ans = [0]*(ans_len)

for a in a_list:
    is_ans[a] += 1
    if is_ans[a] == 1:
        b = 2*a
        while b < ans_len:
            is_ans[b] += 2
            b += a

ans = 0
for a in a_list:
    # print(a, is_ans[a])
    ans += (is_ans[a] == 1)
print(ans)
### BUGGY CODE ###

s = input()
bef = len(s)
ans = 0
while(1):
    s = s.replace('10', '').replace("01", "")
    now = len(s)
    if bef == now:
        break
    else:
        ans += bef-now
        bef = now
print(ans)


### FIXED CODE ###

s = input()

s0 = 0
s1 = 0

for c in s:
    if c == '0':
        s0 += 1
    else:
        s1 += 1

print(min(s0, s1)*2)
### BUGGY CODE ###

import math
def main():
    A,B,N = map(int, input().split())

    max1 = 0
    k1 = math.ceil(B/A)
    k2 = B+1 if B<N else N+1
    for x in range(k1,k2):
        tmp = int(A*x/B) - A*int(x/B)
        max1 = max(max1,tmp)
    print(max1)

main()


### FIXED CODE ###

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

    x = min(B-1,N)
    max1 = int(A*x/B) - A*int(x/B)
    print(max1)

main()
### BUGGY CODE ###

import numpy as np

def Replacing():
    N = int(input())
    A = np.array(list(map(int,input().split())))
    Q = int(input())
    for i in range(Q):
        b, c = map(int,input().split())
        A = np.where(A == b, c, A)
        print(A.sum())
        
Replacing()

### FIXED CODE ###

def Replacing():
    N = int(input())
    A = list(map(int,input().split()))
    lis = [0 for i in range(10 ** 5)]
    res = 0
    for i in A:
        lis[i-1] += 1
        res += i
    
    Q = int(input())
    for i in range(Q):
        b, c = map(int,input().split())
        num = lis[b-1]
        res += (c - b) * num
        lis[b-1] = 0
        lis[c-1] += num
        print(res)
        
Replacing()
### BUGGY CODE ###

import copy
r,c = map(int,input().split())
grid = []
temp = []
limit = r*c
total = 0
count = 0
done = [[0 for _ in range(c)] for _ in range(r)]
for i in range(r):
    next = list(input())
    for j in range(c):
        if next[j]=='#':
            temp.append([i,j])
            total+=1
    grid.append(next)
while(total<limit):
    nextround = []
    while(len(temp)>0):
        x,y = temp.pop()
        # print('X:',x,'Y:',y)
        if x-1>-1:
            if grid[x-1][y] == '.':
                grid[x - 1][y] = '#'
                total +=1
                nextround.append([x-1,y])
        if x+1<r:

            if grid[x+1][y] == '.':
                grid[x + 1][y] = '#'
                total +=1
                nextround.append([x+1, y])
        if y-1>-1:
            if grid[x][y-1] == '.':
                grid[x][y-1] = '#'
                total +=1
                nextround.append([x,y-1])
        if y+1<c:
            if grid[x][y+1] == '.':
                grid[x][y+1] = '#'
                total +=1
                nextround.append([x,y+1])
    temp = copy.deepcopy(nextround)
    count+=1
print(count)

### FIXED CODE ###

r,c = map(int,input().split())
grid = []
temp = []
limit = r*c
total = 0
count = 0
for i in range(r):
    next = list(input())
    for j in range(c):
        if next[j]=='#':
            temp.append([i,j])
            total+=1
    grid.append(next)
while(total<limit):
    nextround = []
    while(len(temp)>0):
        x,y = temp.pop()
        # print('X:',x,'Y:',y)
        if x-1>-1:
            if grid[x-1][y] == '.':
                grid[x - 1][y] = '#'
                total +=1
                nextround.append([x-1,y])
        if x+1<r:

            if grid[x+1][y] == '.':
                grid[x + 1][y] = '#'
                total +=1
                nextround.append([x+1, y])
        if y-1>-1:
            if grid[x][y-1] == '.':
                grid[x][y-1] = '#'
                total +=1
                nextround.append([x,y-1])
        if y+1<c:
            if grid[x][y+1] == '.':
                grid[x][y+1] = '#'
                total +=1
                nextround.append([x,y+1])
    temp = nextround
    count+=1
print(count)
### BUGGY CODE ###

k=int(input())
seven=0
i=0
if k%2==0:
    print(-1)
else:
    while True:
        i+=1
        seven=seven*10+7
        seven = seven % k
        if seven==0:
            print(i)
            break


### FIXED CODE ###

k=int(input())


def get(k):
    ans=7
    i=1
    while True:
        if ans%k==0:
            return i
        ans=(ans*10+7)%k
        i+=1




if k%2==0 or k%5==0:
    print(-1)

else:
    print(get(k))
### BUGGY CODE ###

def main():
  from collections import Counter
  N = int(input())
  S = [input() for _ in range(N)]

  tmp = []
  for s in S:
    tmp.append("".join(sorted(s)))
  cnt = 0
  for i, t in enumerate(tmp):
    for j in range(i+1, N):
      if tmp[i] == tmp[j]:
        cnt += 1
  print(cnt)

if __name__ == "__main__":
  main()

### FIXED CODE ###

def main():
  N = int(input())
  S = [input() for _ in range(N)]

  d = {}
  for i, s in enumerate(S):
    x = "".join(sorted(s))
    if x in d:
      d[x] += 1
    else:
      d[x] = 1
  
  cnt = 0
  for v in d.values():
    if v == 1:
      continue
    if v == 2:
      cnt += 1
    elif v == 3:
      cnt += v
    else:
      cnt += sum(list(range(1,v)))

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

N = int(input())
a = [sorted(input()) for i in range(N)]
count = 0
li = []
for i in a:
    if i in li:
        count+=li.count(i)
    li.append(i)

print(count)

### FIXED CODE ###

N = int(input())
S = [''.join(sorted(input().rstrip())) for _ in range(N)]


from collections import Counter
counter = Counter(S)
answer = sum(x * (x - 1) // 2 for x in counter.values())
print(answer)
### BUGGY CODE ###

N , M = map(int,input().split())
X = list(map(int,input().split()))
X.sort(reverse=True)
diff = []
for i in range(len(X) - 1):
    diff.append(X[i] - X[i + 1])
for _ in range(N - 1):
    if not diff:
        print("0")
        exit()
    else:
        diff.remove(max(diff))
print(sum(diff))

### FIXED CODE ###

import heapq
N , M = map(int,input().split())
X = list(map(int,input().split()))
X.sort(reverse=True)
diff = []
heapq.heapify(diff)
for i in range(len(X) - 1):
    heapq.heappush(diff , -1 * (X[i] - X[i + 1]))
for _ in range(N - 1):
    if not diff:
        print("0")
        exit()
    else:
        heapq.heappop(diff)

print(-1 * sum(diff))
### BUGGY CODE ###

line = input().split(" ")
a = list(map(int, line))
data = [0] * 90001
ans = 0
for i in range(0, a[0]):
    line = input().split(" ")
    temp = list(map(int, line))
    for j in range(0, a[1]):
        data[temp[j]] = [i, j]
times = int(input())
for i in range(0, times):
    line = input().split(" ")
    temp = list(map(int, line))
    nowloc = temp[0]
    ans = 0
    while nowloc != temp[1]:
        ans += abs(data[nowloc][0] - data[nowloc + a[2]][0]) + abs(data[nowloc][1] - data[nowloc + a[2]][1])
        nowloc += a[2]
    print(ans)

### FIXED CODE ###

line = input().split(" ")
a = list(map(int, line))
data = [0] * 90001
ans = 0
for i in range(0, a[0]):
    line = input().split(" ")
    temp = list(map(int, line))
    for j in range(0, a[1]):
        data[temp[j]] = [i, j]

memo = [0] * 90001

for i in range(1, a[0] * a[1]+1):
    if i < a[2]+1:
        memo[i] = 0
    else:
        memo[i] = memo[i - a[2]] + abs(data[i][0] - data[i - a[2]][0]) + abs(data[i][1] - data[i - a[2]][1])
times = int(input())
for i in range(0, times):
    line = list(map(int, input().split(" ")))
    print(memo[line[1]] - memo[line[0]])
### BUGGY CODE ###

from collections import defaultdict
d = defaultdict(int)


n = int(input())
polls = [input() for i in range(n)]

for i in polls:
    d[i] += 1

max_k_list = sorted([kv[0] for kv in d.items() if kv[1] == max(d.values())])

for ans in max_k_list:
    print(ans)

### FIXED CODE ###

import collections

n = int(input())
polls = [input() for i in range(n)]

c = collections.Counter(polls)
maxval = c.most_common()[0][1]

values, counts = zip(*c.most_common())

ans = []

for i in c.most_common():
    if i[1] == maxval:
        ans.append(i[0])
    else:
        break

ans.sort()

for i in ans:
    print(i)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    x, y = map(lambda x: int(x) - 1, input().split())
    G[x].append(y)
    G[y].append(x)

nim = [0] * N

def dfs(v, p):
    for c in G[v]:
        if c != p:
            dfs(c, v)
            nim[v] ^= nim[c]
    nim[v] += 1

dfs(0, -1)
print('Alice' if nim[0] > 1 else 'Bob')

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    x, y = map(lambda x: int(x) - 1, input().split())
    G[x].append(y)
    G[y].append(x)

nim = [0] * N

def dfs(v, p):
    for c in G[v]:
        if c != p:
            dfs(c, v)
            nim[v] ^= nim[c]
    nim[v] += 1

dfs(0, -1)
print('Alice' if nim[0] > 1 else 'Bob')
### BUGGY CODE ###

import itertools
from sys import stdin
N=int(input())
st=list(stdin.readline().strip())
count=0
cnt=0
num=["0","1","2","3","4","5","6","7","8","9"]

num_list= ["".join(i) for i in itertools.product(num,repeat=3)]

for number in num_list:
    for i in range(N):

        if cnt==0 and number[0]==st[i]:
            cnt+=1
        elif cnt==1 and number[1]==st[i]:
            cnt+=1
        elif cnt==2 and number[2]==st[i]:
            cnt+=1
            break
    if cnt==3:
        count+=1
    cnt=0
print(count)

### FIXED CODE ###

def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()
### BUGGY CODE ###

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

flag = True

for i in range(n):
    for j in range(n):
        if i != j and a[i] == a[j]:
            flag = False

if flag:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

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

if len(set(a)) == n:
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

N = int(input())
arr = []
for i in range(N):
    A = str(input())
    if A in arr:
        continue
    else:
        arr.append(str(A))

print(len(arr))

### FIXED CODE ###

N = int(input())
list = {}
for i in range(N):
    A = str(input())
    list[A] = 1

print(len(list))
### BUGGY CODE ###

def post_pd(t):
    for i in t:
        if i == '?':
            t = t[:t.index('?')] + 'D' + t[t.index('?')+1:]
    
    return t

if __name__ == '__main__':
    t = input()
    print(post_pd(t))

### FIXED CODE ###

def post_pd(t):
    string_list = ''
    for i in t:
        if i == '?':
            string_list = string_list + 'D'
        else:
            string_list = string_list + i
    
    return string_list

if __name__ == '__main__':
    t = input()
    print(post_pd(t))
### BUGGY CODE ###

st = input()

sample = ['dream', 'dreamer', 'erase', 'eraser']
sample_edit = ['dream', 'eraser','erase', 'er']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']

ret = 'NO'
reg_len = 0
fd_word = ''
dream_flg = False
end_flg = False

while( len(st) != 0 ):
  if reg_len == len(st):
    break
  
  reg_len = len(st)
  for i in range(len(sample_edit)):
    fd = st.startswith(sample_edit[i])
    
    if fd > 0:
      
      #print(st,i,dream_flg)
      st = ''.join(st[len(sample_edit[i]):len(st)])
        
      if sample_edit[i] == 'dream':
        dream_flg = True
      elif sample_edit[i] == 'er':
        if dream_flg == False:
          end_flg = True
        else:
          dream_flg = False
      
      break
    
        
  if end_flg == True:
    break
    
  if len(st) == 0:
    ret = 'YES'
    
  #print(st)
  #print(len(st))

print( ret )

### FIXED CODE ###

st = input()

sample = ['dream', 'dreamer', 'erase', 'eraser']
sample_edit = ['dream', 'eraser','erase', 'er']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']

ret = 'NO'
reg_len = 0
fd_word = ''
dream_flg = False
end_flg = False

word = ''
length = len(sample_edit)

#while( len(st) != 0 ):
while( True ):
  if reg_len == len(st):
    break
  
  reg_len = len(st)
  for i in range(length):
    word = sample_edit[i]
    fd = st.startswith(word)
    
    if fd > 0:
      
      #print(st,i,dream_flg)
      #st = ''.join(st[len(word):len(st)])
      st = st[len(word):len(st)]
        
      if word == 'dream':
        dream_flg = True
      elif word == 'er':
        if dream_flg == False:
          end_flg = True
        else:
          dream_flg = False
      
      break
    
        
  if end_flg == True:
    break
    
  if len(st) == 0:
    ret = 'YES'
    break
    
  #print(st)
  #print(len(st))

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

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

p1, p2, p3, p4, p5, p6 = n, 0, 0, 0, 0, 0
ans = 0

def carry(p1, p2, num):
    if p1>=num:
        p1 -= num
        p2 += num
    elif 0<p1<num:
        p2 += p1
        p1 = 0
    return p1, p2

while p6!=n:
    ans += 1
    p5, p6 = carry(p5, p6, e)
    p4, p5 = carry(p4, p5, d)
    p3, p4 = carry(p3, p4, c)
    p2, p3 = carry(p2, p3, b)
    p1, p2 = carry(p1, p2, a)

print(ans)

### FIXED CODE ###

from math import ceil, floor
#ceil()  # 切り上げ。常にup
#floor()  # 切り捨て。常にdown
#int()  # 常に0に近く（正負で挙動違う）
#round(f),  round(f, 1)  # 四捨五入（第二引数で小数点桁数を指定）
n = int(input())
l = [int(input()) for _ in range(5)]
print(ceil(n / min(l)) + 4)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
from bisect import bisect_left 
from collections import deque

def count_edge(a,b):
    global edge,AB
    if a>b:
        a,b=b,a
    edge[bisect_left(AB,(a,b))]+=1

def main():
    global edge,AB
    N,M=map(int,input().split())
    data=[[] for i in range(N+1)]
    AB=[]
    edge=[0]*M
    count=[0]*(N+1)
    for i in range(M):
        A,B=map(int,input().split())
        if A>B:
            A,B=B,A
        AB.append((A,B))
        data[A].append(B)
        data[B].append(A)
        count[A]+=1
    AB.sort()

    if M%2==1:
        print(-1)
        sys.exit()

    parent=[0]*(N+1)
    que=[1]
    flag=[0]*(N+1)
    flag[1]=1
    parent[1]=1
    lsls=deque([])
    while que:
        h=[]
        for u in que:
            for v in data[u]:
                if flag[v]==0:
                    flag[v]=1
                    parent[v]=u
                    h.append(v)
                    if count[v]%2==1:
                        lsls.appendleft(v)
        que=h

    for i in lsls:
        if count[i]%2==0:
            continue
        else:
            count[i]+=1
            while True:
                j=parent[i]
                if i==j:
                    break
                count_edge(i,j)
                if count[j]%2==1:
                    count[j]+=1
                    break
                i=j
            
    for i in range(M):
        if edge[i]%2==0:
            print(*AB[i])
        else:
            print(*AB[i][::-1])
    
if __name__=="__main__":
    main()

### FIXED CODE ###

import sys
input=sys.stdin.readline
from bisect import bisect_left 
from collections import deque

def count_edge(a,b):
    global edge,AB
    if a>b:
        a,b=b,a
    edge[bisect_left(AB,(a,b))]+=1

def main():
    global edge,AB
    N,M=map(int,input().split())
    data=[[] for i in range(N+1)]
    AB=[]
    edge=[0]*M
    count=[0]*(N+1)
    for i in range(M):
        A,B=map(int,input().split())
        if A>B:
            A,B=B,A
        AB.append((A,B))
        data[A].append(B)
        data[B].append(A)
        count[A]^=1
    AB.sort()

    if M%2==1:
        print(-1)
        sys.exit()

    parent=[0]*(N+1)
    que=[1]
    parent[1]=1
    lsls=deque([])
    while que:
        h=[]
        for u in que:
            for v in data[u]:
                if parent[v]==0:
                    parent[v]=u
                    h.append(v)
                    if count[v]%2==1:
                        lsls.appendleft(v)
        que=h

    for i in lsls:
        if count[i]==0:
            continue
        else:
            count[i]=0
            while True:
                j=parent[i]
                if i==j:
                    break
                count_edge(i,j)
                if count[j]==1:
                    count[j]=0
                    break
                i=j
            
    for i in range(M):
        if edge[i]%2==0:
            print(*AB[i])
        else:
            print(*AB[i][::-1])
    
if __name__=="__main__":
    main()
### BUGGY CODE ###

N =int(input())
s = sorted(list(sorted(input()) for i in range(N)))
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if s[i]==s[j]:
            cnt+=1
        else: break
print(cnt)

### FIXED CODE ###

import collections

N =int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
cnt = 0
ans =0
for i in set(s):
    cnt = c[i]
    ans += cnt*(cnt-1)//2
print(ans)
### BUGGY CODE ###

s = input()
n = len(s)
target = 2019
res = 0
for i in range(n):
    j = i + 4
    while j < n:
        if int(s[i:j+1]) % target == 0:
            res += 1
            j += 4
        j += 1
print(res)

### FIXED CODE ###

from collections import defaultdict
s = input()
n = len(s)
target = 2019
res = 0
dic = defaultdict(int)
dic[0] = 1
s = s[::-1]
num, d = 0, 1
for char in s:
    num += int(char) * d
    num %= target
    d *= 10
    d %= target
    dic[num] += 1
for i in dic.values():
    res += i * (i -1) //2
print(res)
### BUGGY CODE ###

from functools import reduce
from operator import mul
import sys

input = sys.stdin.readline

n = int(input())
An = [int(x) for x in input(). split()]

j = 1000000000000000000
ans = 1
ans = reduce(mul, An)


if ans > j :
    print(-1)
    
else :
    print(ans)



### FIXED CODE ###


n = int(input())
An = [int(x) for x in input().split()]
An.sort(reverse=True)

if 0 in An:
    print(0)
    exit()

j = 10 ** 18
ans = 1
for i in range(n):
    if ans > j:
        print(-1)
        quit()
    ans *= An[i]

if ans > j :
    print(-1)
    
else :
    print(ans)