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

import numpy as np
from collections import defaultdict
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0] -q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

#　aの逆元を求める
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def combination(m,k):
    res = 1
    for i in range(1,m+1):
        res = res*i%(10**9+7)
    for i in range(1,k+1):
        res = res*mod_inv(i,10**9+7)
    for i in range(1,m-k+1):
        res = res*mod_inv(i,10**9+7)
    return res%(10**9+7)

def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    ls.insert(0,0)
    cumsum = np.cumsum(ls)
    cnt = defaultdict(int)
    for i in cumsum:
        cnt[i] +=1
    ans = 0
    for i in cnt.values():
        if i==1:
            pass
        else:
            ans += combination(i,2)
    print(ans)



if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict
def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    cumsum = [0]*(n+1)
    for i in range(1,n+1):
        cumsum[i] = cumsum[i-1]+ls[i-1]
    cnt = defaultdict(int)
    for i in cumsum:
        cnt[i] +=1
    ans = 0
    for i in cnt.values():
        if i==1:
            continue
        ans += int(i*(i-1)/2)
    print(ans)



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

a = int(input())
b = input().split()
c = 0
for i in range(len(b)-1):
    for j in range(i+1,len(b)):
        if b[i] == b[j]:
            print('NO')
            c = 1
            break
    if c == 1:
        break

if c == 0:
    print('YES')

### FIXED CODE ###

a = int(input())
b = input().split()
mydict = {}
for i in range(len(b)):
    mydict[b[i]] = 1

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

a = input()
b = input()
c = input()
A, B, C = len(a), len(b), len(c)
ab, bc, ac = [True] * 16000, [True] * 16000, [True] * 16000

for i in range(A):
    if a[i] == '?':
        continue
    for j in range(B):
        if b[j] != '?' and a[i] != b[j]:
            ab[i-j+8000]= False
for i in range(B):
    if b[i] == '?':
        continue
    for j in range(C):
        if c[j] != '?' and b[i] != c[j]:
            bc[i-j+8000]= False
for i in range(A):
    if a[i] == '?':
        continue
    for j in range(C):
        if c[j] != '?' and a[i] != c[j]:
            ac[i-j+8000]= False
ans = 6000

for i in range(-4000, 4000):
    for j in range(-4000, 4000):
        if ab[i+8000] and bc[j-i+8000] and ac[j+8000]:
            L = min(0, min(i, j))
            R = max(A, max(B+i, C+j))
            ans = min(ans, R-L)
print(ans)

### FIXED CODE ###

a = input()
b = input()
c = input()
A, B, C = len(a), len(b), len(c)
ab, bc, ac = [1] * 16000, [1] * 16000, [1] * 16000

for i in range(A):
    if a[i] == '?':
        continue
    for j in range(B):
        if b[j] != '?' and a[i] != b[j]:
            ab[i-j+8000]= 0
for i in range(B):
    if b[i] == '?':
        continue
    for j in range(C):
        if c[j] != '?' and b[i] != c[j]:
            bc[i-j+8000]= 0
for i in range(A):
    if a[i] == '?':
        continue
    for j in range(C):
        if c[j] != '?' and a[i] != c[j]:
            ac[i-j+8000]= 0
ans = 6000

for i in range(-4000, 4000):
    for j in range(-4000, 4000):
        if ab[i+8000] and bc[j-i+8000] and ac[j+8000]:
            L = min(0, min(i, j))
            R = max(A, max(B+i, C+j))
            ans = min(ans, R-L)
print(ans)
### BUGGY CODE ###

def isValidNumOfBill(x, y, z, N):
    return x + y + z == N

def isValidSumOfMoney(x, y, z, Y):
    return 10000 * x + 5000 * y + 1000 * z == Y

def outputResult(x, y, z):
    print('{x:d} {y:d} {z:d}'.format(x=x, y=y, z=z))

def outputFailure():
    print('-1 -1 -1')

def searchA(N, Y):
    # define range
    xlim = range(0, Y // 10000 + 1)
    ylim = range(0, Y // 5000 + 1)
    zlim = range(0, Y // 1000 + 1)

    for x in xlim:
        for y in ylim:
            for z in zlim:
                # print(x, y, z)
                if not isValidNumOfBill(x, y, z, N):
                    continue
                if isValidSumOfMoney(x, y, z, Y):
                    return (x, y, z)

def searchB(N, Y):
    # 最初に金額を合わせる
    x = Y // 10000
    y = (Y - 10000 * x) // 5000
    z = (Y - 10000 * x - 5000 * y) // 1000

    while x >= 0:
        while y >= 0:
            y -= 1
            z += 5
        x -= 1
        y += 2


def main():
    # read 'N Y'
    args = input().split(" ")
    N = int(args[0])
    Y = int(args[1]) 

    # search for 10000x + 5000y + 1000z = Y
    result = searchA(N, Y)
    if result is not None:
        x, y, z = result
        outputResult(x, y, z)
    else:
        outputFailure()

if __name__ == '__main__':
    main()


### FIXED CODE ###

def isValidNumOfBill(x, y, z, N):
    return x + y + z == N

def isValidSumOfMoney(x, y, z, Y):
    return 10000 * x + 5000 * y + 1000 * z == Y

def outputResult(x, y, z):
    print('{x:d} {y:d} {z:d}'.format(x=x, y=y, z=z))

def outputFailure():
    print('-1 -1 -1')

def searchA(N, Y):
    # define range
    xlim = range(0, Y // 10000 + 1)
    ylim = range(0, Y // 5000 + 1)
    zlim = range(0, Y // 1000 + 1)

    for x in xlim:
        for y in ylim:
            for z in zlim:
                # print(x, y, z)
                if not isValidNumOfBill(x, y, z, N):
                    continue
                if isValidSumOfMoney(x, y, z, Y):
                    return (x, y, z)

def searchB(N, Y):
    # 最初に金額を合わせる
    calcX = lambda Y: Y // 10000
    calcY = lambda x, Y: (Y - 10000 * x) // 5000
    calcZ = lambda x, y, Y: (Y - 10000 * x - 5000 * y) // 1000
    x = calcX(Y)
    y = calcY(x, Y)
    z = calcZ(x, y, Y)

    while x >= 0:
        while y >= 0:
            # print(x, y, z)
            if sum((x, y, z)) == N:
                return (x, y, z)
            y -= 1
            z = calcZ(x, y, Y)
        x -= 1
        y = calcY(x, Y)
        z = calcZ(x, y, Y)

def main():
    # read 'N Y'
    args = input().split(" ")
    N = int(args[0])
    Y = int(args[1]) 

    # search for 10000x + 5000y + 1000z = Y
    # result = searchA(N, Y)
    result = searchB(N, Y)
    if result is not None:
        x, y, z = result
        outputResult(x, y, z)
    else:
        outputFailure()

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

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

    B = [(A[i], i) for i in range(N)]
    B.sort(key = lambda x: x[0], reverse = True)

    DP = [[0] * (N + 1) for _ in range(N + 1)]

    for i, b in enumerate(B):
        a = b[0]
        tmp = b[1]
        for x in range(i + 1):
            DP[x + 1][i - x] = max(DP[x + 1][i - x], DP[x][i - x] + a * abs(tmp - x))
            DP[x][i - x + 1] = max(DP[x][i - x + 1], DP[x][i - x] + a * abs((N - tmp - 1) - (i - x)))

    ans = 0
    for i, dp in enumerate(DP):
        ans = max(ans, dp[N - i])

    print (ans)

    # for tmp in DP:
    #     print (tmp)

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

B = [(A[i], i) for i in range(N)]
B.sort(key = lambda x: x[0], reverse = True)

DP = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(N):
    a = B[i][0]
    tmp = B[i][1]
    for x in range(i + 1):
        DP[x + 1][i - x] = max(DP[x + 1][i - x], DP[x][i - x] + a * abs(tmp - x))
        DP[x][i - x + 1] = max(DP[x][i - x + 1], DP[x][i - x] + a * abs((N - tmp - 1) - (i - x)))

ans = 0
for i in range(N + 1):
    ans = max(ans, DP[i][N - i])

print (ans)

# for tmp in DP:
#     print (tmp)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    from math import gcd
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    S = 1
    d = dict()
    for x in A:
        S *= x
    flag = True
    for x in A:
        if gcd(S//x, x) == 1:
            continue
        else:
            flag = False
            break
    if flag:
        print("pairwise coprime")
    else:
        g = A[0]
        for i in range(1, N):
            g = gcd(A[i], g)
        if g == 1:
            print("setwise coprime")

        else:
            print("not coprime")


main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    from math import gcd
    N = int(input())
    A = list(map(int, input().split()))
    g = A[0]
    M = max(A)
    X = [i for i in range(M+1)]
    S = [True for i in range(M+1)]
    S[0] = False
    S[1] = False

    for i in range(1, M+1):
        if S[i]:
            for j in range(i, M+1, i):
                if S[j]:
                    S[j] = False
                    X[j] = i
    flag = True
    s = set()
    ls = 0
    for x in A:
        tmp = set()
        while(X[x] != 1):
            tmp.add(X[x])
            x //= X[x]
        l = len(tmp)
        s |= tmp
        if len(s) == ls + l:
            ls += l
            continue
        else:
            flag = False
            break

    if flag:
        print("pairwise coprime")
    else:
        for x in A[1:]:
            g = gcd(g, x)
        if g == 1:
            print("setwise coprime")

        else:
            print("not coprime")


main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-

S = input().strip()
#-----

cnt=0
while (S.count("01") != 0) or (S.count("10") != 0):
    cnt += S.count("01")
    S = S.replace("01", "")
    
    cnt += S.count("10")
    S = S.replace("10", "")
    
print(cnt*2)


### FIXED CODE ###

# -*- coding: utf-8 -*-

S = input().strip()
#-----

num_red = S.count("0")
num_blue = len(S) - num_red

print( min(num_red,num_blue) * 2 )
### BUGGY CODE ###

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

def gcd(a, b):
  if (min(a, b) == 0):
    return max(a, b)
  elif (a > b):
    return gcd(b, a % b)
  else:
    return gcd(a, b % a)

gcd_forward = []
gcd_all = numbers[0]
for i in range(0, N - 1):
  if (gcd_all > 1):
    gcd_all = gcd(gcd_all, numbers[i])
  gcd_forward.append(gcd_all)

gcd_backward = []
gcd_all = numbers[-1]
for i in range(N - 1, 0, -1):
  if (gcd_all > 1):
    gcd_all = gcd(gcd_all, numbers[i])
  gcd_backward.insert(0, gcd_all)

gcd_forward.insert(0, gcd_backward[0])
gcd_backward.append(gcd_forward[-1])

gcd_max = 1
for i in range(N):
  if (gcd_forward[i] > 1 and gcd_backward[i] > 1):
    gcd_max = max(gcd_max, gcd(gcd_forward[i], gcd_backward[i]))
  
print(gcd_max)


### FIXED CODE ###

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

def gcd(a, b):
  r = a % b
  while (r > 0):
    a = b
    b = r
    r = a % b
  return b

gcd_forward = [numbers[0]]
for i in range(1, N - 1):
  gcd_all = gcd(gcd_forward[-1], numbers[i])
  gcd_forward.append(gcd_all)

gcd_backward = [numbers[-1]]
for i in range(N - 2, 0, -1):
  gcd_all = gcd(gcd_backward[-1], numbers[i])
  gcd_backward.append(gcd_all)

gcd_max = 1
for i in range(N):
  gcd_temp = 1
  if (i == 0):
    gcd_temp = gcd_backward[-1]
  elif (i == N - 1):
    gcd_temp = gcd_forward[-1]
  else:
    gcd_temp = gcd(gcd_forward[i - 1], gcd_backward[N - 2 - i])
  gcd_max = max(gcd_max, gcd_temp)
  
print(gcd_max)
### BUGGY CODE ###

import copy
import math
 
d,g = map(int,input().split())
P = []
C = []
for i in range(d):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
 
m = 10**9
def score(point = 0, n = 0, now=0, done=[]):
    global m
    if point >= g:
        if m > n: m = n
    elif point+100*(now+1)*P[now] >= g:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: 
            m = n
    else:
        done.append(now)
        for i in range(d):
            if not i in done:
                score(point+P[now]*100*(now+1) + C[now], n + P[now], i, copy.copy(done))
 
for i in range(d):
    done = []
    score(0,0,i,done)
print(m)

### FIXED CODE ###

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)
### BUGGY CODE ###

n, k = (int(x) for x in input().split())
p = list(int(x) for x in input().split())
sump = []

for i in range(n - k + 1):
    sump.append(sum(p[i: k + i], k))
print(max(sump) / 2)


### FIXED CODE ###

import numpy as np

n, k = (int(x) for x in input().split())
p = np.array(list(int(x) for x in input().split()))

p = (p + 1) / 2

sump = []
e = []
s = 0

for i in range(len(p)):
    s += p[i]
    sump.append(s)

sump.insert(0, 0)
sump = np.array(sump)

for i in range(n - k + 1):
    e.append(sump[i + k] - sump[i])


print(max(e))
### BUGGY CODE ###

import fileinput


class Cache():
    def __init__(self, n_1, n_2, n_3):
        self._n_1 = n_1 + n_2 + n_3 + 1
        self._n_2 = n_2 + n_3 + 1
        self._n_3 = n_3 + 1

        self._arr = [-1] * (self._n_1 * self._n_2 * self._n_3)

    def get(self, n_1, n_2, n_3):
        return self._arr[n_1 + n_2 * self._n_1 + n_3 * self._n_1 * self._n_2]

    def add(self, n_1, n_2, n_3, val):
        self._arr[n_1 + n_2 * self._n_1 + n_3 * self._n_1 * self._n_2] = val

def num_turns(total, n_1, n_2, n_3, cache):
    if cache.get(n_1, n_2, n_3) != -1:
        return cache.get(n_1, n_2, n_3)

    with_sushi = n_1 + n_2 + n_3 

    if with_sushi == 0: return 0

    res = total / with_sushi

    if n_1 > 0:
        p = n_1 / with_sushi
        res += p * num_turns(total, n_1 - 1, n_2, n_3, cache)
    
    if n_2 > 0:
        p = n_2 / with_sushi
        res += p * num_turns(total, n_1 + 1, n_2 - 1, n_3, cache)

    if n_3 > 0:
        p = n_3 / with_sushi
        res += p * num_turns(total, n_1, n_2 + 1, n_3 - 1, cache)

    cache.add(n_1, n_2, n_3, res)
    return res

inp = fileinput.FileInput()
total = int(inp.readline())

n_1 = 0
n_2 = 0
n_3 = 0

for v in inp.readline().split(" "):
    v = int(v)
    if v == 1:
        n_1 += 1
    if v == 2:
        n_2 += 1
    if v == 3:
        n_3 += 1

print(num_turns(total, n_1, n_2, n_3, Cache(n_1, n_2, n_3)))

### FIXED CODE ###

import fileinput


def num_turns(total, n_1, n_2, n_3):
    _n_1 = n_1 + n_2 + n_3 + 1
    _n_2 = n_2 + n_3 + 1
    _n_3 = n_3 + 1

    _arr = [0.0] * (_n_1 * _n_2 * _n_3)

    for i_3 in range(n_3 + 1):
        for i_2 in range(n_2 + 1 + n_3 - i_3):
            for i_1 in range(n_1 + 1 + n_2 + n_3 - i_3 - i_2):
                with_sushi = i_1 + i_2 + i_3
                if with_sushi == 0:
                    continue
                expectation = total / with_sushi
                if i_1 > 0:
                    p = i_1 / with_sushi
                    expectation += p * _arr[(i_1 - 1) + i_2 * _n_1 + i_3 * _n_1 * _n_2]

                if i_2 > 0:
                    p = i_2 / with_sushi
                    expectation += p * _arr[i_1 + 1 + (i_2 - 1) * _n_1 + i_3 * _n_1 * _n_2]

                if i_3 > 0:
                    p = i_3 / with_sushi
                    expectation += p * _arr[i_1 + (i_2 + 1) * _n_1 + (i_3 - 1) * _n_1 * _n_2]
                _arr[i_1 + i_2 * _n_1 + i_3 * _n_1 * _n_2] = expectation

    return _arr[n_1 + n_2 * _n_1 + n_3 * _n_1 * _n_2]


inp = fileinput.FileInput()
total = int(inp.readline())

n_1 = 0
n_2 = 0
n_3 = 0

for v in inp.readline().split(" "):
    v = int(v)
    if v == 1:
        n_1 += 1
    if v == 2:
        n_2 += 1
    if v == 3:
        n_3 += 1

print(num_turns(total, n_1, n_2, n_3))
### BUGGY CODE ###

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

while True:
    a.sort(reverse = True)
    x = True
    for i in range(n):
        if a[i] % 2 == 0:
            if x:
                a[i] = a[i] // 2
                x = False
            else:
                a[i] *= 3
        else:
            a[i] * 3
    if x:
        print(t)
        exit(0)
    else:
        t += 1

### FIXED CODE ###

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

for i in range(n):
    while a[i] % 2 == 0:
        a[i] = a[i] // 2
        t += 1
        
print(t)
### BUGGY CODE ###

s = input()
t = input()
obj = {}

loop_num = 0
temp_num = -1

for i in range(len(s)):
    char = s[i]
    if not (char in obj):
        obj[char] = [i]
    else:
        obj[char].append(i)

for i in range(len(t)):
    char = t[i]
    if not (char in obj):
        loop_num = -1
        break
    else:
        filtered = [x for x in obj[char] if x > temp_num]
        if len(filtered) == 0:
            loop_num += 1
            temp_num = obj[char][0]
        else:
            temp_num = filtered[0]

if(loop_num == -1):
    print(-1)
else:
    print(loop_num * len(s) + temp_num + 1)

### FIXED CODE ###

from bisect import bisect_right

s = input()
t = input()
obj = {}

loop_num = 0
temp_num = -1

for i in range(len(s)):
    char = s[i]
    if not (char in obj):
        obj[char] = [i]
    else:
        obj[char].append(i)

for i in range(len(t)):
    char = t[i]
    if not (char in obj):
        loop_num = -1
        break
    else:
        next_index = bisect_right(obj[char], temp_num)
        if next_index == len(obj[char]):
            loop_num += 1
            temp_num = obj[char][0]
        else:
            temp_num = obj[char][next_index]

if(loop_num == -1):
    print(-1)
else:
    print(loop_num * len(s) + temp_num + 1)
### BUGGY CODE ###

import math

a, b, n = map(int, input().split())
ans = math.floor(a*n/b) - a*math.floor(n/b)
x = b-1
while x <= n:
    ans = max(ans, math.floor(a*x/b) - a*math.floor(x/b))
    x += b
print(ans)

### FIXED CODE ###

import math
a, b, n = map(int, input().split())
x = min(b-1, n)
ans = math.floor(a*x/b) - a*math.floor(x/b)
print(ans)
### BUGGY CODE ###

# https://img.atcoder.jp/abc123/editorial.pdf
# 問題D: Cake 123 解法 #2 - 「ある条件」を満たす最大106307通りを全部ソート

def solve(X, Y, Z, K, A, B, C):
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    ABC = []
    for i1, a in enumerate(A, start=1):
        for i2, b in enumerate(B, start=1):
            for i3, c in enumerate(C, start=1):
                if i1 * i2 * i3 <= K:
                    ABC.append(a + b + c)
    ABC.sort(reverse=True)
    ABC = ABC[:K]

    print("\n".join(map(str, ABC)))

if __name__ == "__main__":
    X, Y, Z, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    solve(X, Y, Z, K, A, B, C)

### FIXED CODE ###

from collections import defaultdict

def append(m, printed, cand_a, cand_b, cand_c):
    key = "{}-{}-{}".format(cand_a, cand_b, cand_c)
    key2 = "{}-{}-{}".format(cand_a-1, cand_b, cand_c)
    key3 = "{}-{}-{}".format(cand_a, cand_b-1, cand_c)
    key4 = "{}-{}-{}".format(cand_a, cand_b, cand_c-1)
    if not key in printed \
            and cand_a < len(A) \
            and cand_b < len(B) \
            and cand_c < len(C) \
            and not key in m \
            and not key2 in m \
            and not key3 in m \
            and not key4 in m :
#       print("Appended {}".format(key))
        m[key] = A[cand_a] + B[cand_b] + C[cand_c]
    return m

X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

a = 0
b = 0
c = 0

n_print = 0
#print(A, B, C)
memo = {}
printed = defaultdict(lambda: False)
while True:
    summ = A[a] + B[b] + C[c]
    printed["{}-{}-{}".format(a, b, c)] = True

    print(summ)

#   print(memo.items())
#   print(a, b, c)
#   print("")

    n_print += 1
    if n_print == K:
        break

    memo = append(memo, printed, a+1, b, c)
    memo = append(memo, printed, a, b+1, c)
    memo = append(memo, printed, a, b, c+1)

    max_k = max(memo, key=memo.get)
    a, b, c = max_k.split("-")
    a = int(a)
    b = int(b)
    c = int(c)
        
    memo.pop(max_k)
#   print("Pop {}".format(max_k))
### BUGGY CODE ###

a=int(input())
List=list(map(int,input().split()))
c =1
i =1
while i < a:
    if i-1 == 0:
        if List[i-1] < List[i]:
            c +=1
            i +=1
print(c)

### FIXED CODE ###

a=int(input())
List=list(map(int,input().split()))
c = 0

for i in range(a):
    if max(List[:i+1]) == List[i]:
        c +=1
print(c)
### BUGGY CODE ###

t = 10**18

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

ans = 1
for i in range(n):
    ans = ans * li[i]

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

### FIXED CODE ###

import sys

t = 10**18


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

if li.count(0) >= 1:
    print(0)
    sys.exit()

ans = 1
for i in range(n):
    ans = ans*li[i]
    if ans > t:
        print(-1)
        sys.exit()

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

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

for k in range(10**9+1):
    if abs(a-k)==abs(b-k):
        print(k)
        c=1
        break

if c!=1:
    print("IMPOSSIBLE")

### FIXED CODE ###

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

if (a+b) % 2==1:
    print("IMPOSSIBLE")

else:
    k=int((a+b)/2)
    if abs(a-k)==abs(b-k):
        print(k)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,k,q=map(int,input().split())
A=[int(input()) for _ in range(q)]

for i in range(1,n+1):
  if k-(q-A.count(i))<=0:
    print('No')
  else:
    print('Yes')


### FIXED CODE ###

import sys
import itertools
input = sys.stdin.readline
n,k,q=map(int,input().split())
A=[int(input()) for _ in range(q)]

ans=[k]*n
for i in range(q):
  ans[A[i]-1]+=1
for i in range(n):
  if ans[i]-q>0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

import sys
input=sys.stdin.readline

from collections import deque
N,M=map(int,input().split())
if M==0:
    print("Yes")
    quit()
G=[[] for i in range(N)]
for i in range(M):
    l,r,d=map(int,input().split())
    G[l-1].append((l-1,r-1,d))
    G[r-1].append((r-1,l-1,-d))
x=["a"]*N
y=[1]*N
z=[[0]*N for i in range(N)]
stack=deque()
for i in range(N):
    if y[i]:
        stack.extend(G[i])
        y[i]=0
    if len(stack)==0:
        continue
    while(stack):
        l,r,d=stack.popleft()
        if x[l]=="a":
            x[l]=0
        if x[r]=="a":
            x[r]=x[l]+d
            continue
        if x[r]!=x[l]+d:
            print("No")
            quit()
        y[r]=0
        z[l][r]=1
        for l1,r1,d1 in G[r]:
            if z[l1][r1]:
                continue
            stack.append((l1,r1,d1))
if max(x)-min(x)>10**9:
    print("No")
else:
    print("Yes")


### FIXED CODE ###

#重み付きUnion-Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        px = find(par[x])
        wei[x] += wei[par[x]]
        par[x] = px
        return px

#xの根から距離
def weight(x):
    find(x)
    return wei[x]


#w[y]=w[x]+wとなるようにxとyを併合
def unite(x,y,w):
    w += wei[x]-wei[y]
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
            w = -w
        par[x] += par[y]
        par[y] = x
        wei[y] = w
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#x,yが同じ集合に属するときのwei[y]-wei[x]
def diff(x,y):
    return weight(y)-weight(x)

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

#初期化
#par:根なら-size,子なら親の頂点
#wei:親からの距離,根なら0
par = [-1]*n
wei = [0]*n

for i in range(m):
    l,r,d = map(int,input().split())
    l,r = l-1,r-1
    if same(l,r):
        if d != diff(l,r):
            print('No')
            exit()
    else:
        unite(l,r,d)
print('Yes')