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

import sys
sys.setrecursionlimit(10**9)

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

dp = [0] * N
def dfs(v, dist):
    for i in path[v]:
        dp[v] = max(dp[v], dfs(i, dist+1))
    return dist

for i in range(N):
    dfs(i, 0)

print(max(dp))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

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

dp = [-1] * N
def dfs(v):
    if dp[v] > -1:
        return dp[v] + 1
    ret = 0
    for i in path[v]:
        ret = max(ret, dfs(i))
    dp[v] = ret
    return ret + 1


for i in range(N):
    if dp[i] < 0:
        dfs(i)

print(max(dp))
### BUGGY CODE ###

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

# memo = [-1 for _ in range(n)]
step_now = 0
step_1   = 0
step_2   = 0
DIV_NUM = 1000000007
if 1 in a_list:
    step_now = 0
else:
    step_now = 1
for i in range(1, n):
    if i == 1:
        step_1 = step_now
        if i+1 in a_list:
            step_now = 0
        else:
#             memo[i] = (memo[0] + 1) % DIV_NUM
            step_now = step_1 + 1
    else:
        step_2 = step_1
        step_1 = step_now
        if i+1 in a_list:
            step_now = 0
        else:
#             memo[i] = (memo[i-1] + memo[i-2]) % DIV_NUM
            step_now = (step_1 + step_2) % DIV_NUM
    if step_now ==  step_1 == step_2 == 0:
        break

print(step_now)

### FIXED CODE ###

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

# memo = [-1 for _ in range(n)]
step_now = 0
step_1   = 0
step_2   = 0
DIV_NUM = 1000000007
if 1 in a_list:
    a_list.pop(0)
    step_now = 0
else:
    step_now = 1
for i in range(1, n):
    if i == 1:
        step_1 = step_now
        if i+1 in a_list:
            a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[0] + 1) % DIV_NUM
            step_now = step_1 + 1
    else:
        step_2 = step_1
        step_1 = step_now
        if i+1 in a_list:
            a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[i-1] + memo[i-2]) % DIV_NUM
            step_now = (step_1 + step_2) % DIV_NUM
    if step_now ==  step_1 == step_2 == 0:
        break

print(step_now)
### BUGGY CODE ###

# D - Equals

from collections import deque

N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

neighbor = [[] for _ in range(N)]
for idx in range(M):
    neighbor[xy[idx][0]-1].append(xy[idx][1]-1)
    neighbor[xy[idx][1]-1].append(xy[idx][0]-1)
    
can_swap = []
visited = [-1]*N

for start in range(N):
    if visited[start] == -1:
        tmp = [start] # startから到達可能なpointのリスト
        d = deque([start])
        while d:
            current_point = d.pop()
            visited[current_point] = 1
            for next_point in neighbor[current_point]:
                if visited[next_point] == -1:
                    d.append(next_point)
                    tmp.append(next_point)
        can_swap.append(tmp)                

ans = 0
for idx_group in can_swap:
    tmp_p = [p[idx]-1 for idx in idx_group]
    ans += len(set(tmp_p) & set(idx_group))

print(ans)

### FIXED CODE ###

# D - Equals

from collections import deque

N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

neighbor = [[] for _ in range(N)]
for idx in range(M):
    neighbor[xy[idx][0]-1].append(xy[idx][1]-1)
    neighbor[xy[idx][1]-1].append(xy[idx][0]-1)
    
can_swap = []
visited = [-1]*N

for start in range(N):
    if visited[start] == -1:
        tmp = [start] # startから到達可能なpointのリスト
        d = deque([start])
        while d:
            current_point = d.pop()
            visited[current_point] = 1
            for next_point in neighbor[current_point]:
                if visited[next_point] == -1:
                    d.append(next_point)
                    tmp.append(next_point)
        can_swap.append(tmp)                

ans = 0
for idx_group in can_swap:
    tmp_p = [p[idx]-1 for idx in idx_group]
    ans += len(set(tmp_p) & set(idx_group))

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

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

import numpy as np

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

MOD = 10 ** 9 + 7

U = 6*10**5 + 100
fact = [1] * (U+1)
for n in range(1,U+1):
    fact[n] = fact[n-1]*n%MOD
fact_inv = [1] * (U+1)
fact_inv[U] = pow(fact[U],MOD-2,MOD)
for n in range(U,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD

fact = np.array(fact,dtype=np.int64)
fact_inv = np.array(fact_inv,dtype=np.int64)

U = N - M
comb = fact[U] * fact_inv[:U+1] % MOD * fact_inv[U::-1] % MOD
comb[1::2] *= (-1)

F = np.zeros(N+M+1,dtype=np.int64)
F[M:N+1] = comb

P = np.zeros(R+1,dtype=np.int64)
for i,x in enumerate(F[1:],1):
    P[::i] += x

P[M:] -= P.copy()[:-M]
P %= MOD

# (1-x)^{N+1}で割る
Q = fact[N:N+R+1] * fact_inv[:R+1] % MOD * fact_inv[N] % MOD

def f(R):
    total = fact[R+N] * fact_inv[R] % MOD * fact_inv[N] % MOD
    x = (Q[R::-1] * P[:R+1] % MOD).sum() % MOD
    coef = fact[N] * fact_inv[M] % MOD * fact_inv[N-M] % MOD
    return (total - x*coef)%MOD

answer = (f(R) - f(L-1))%MOD
print(answer)

### FIXED CODE ###

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

import numpy as np

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

MOD = 10 ** 9 + 7

U = 6*10**5 + 100
fact = [1] * (U+1)
for n in range(1,U+1):
    fact[n] = fact[n-1]*n%MOD
fact_inv = [1] * (U+1)
fact_inv[U] = pow(fact[U],MOD-2,MOD)
for n in range(U,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD

fact = np.array(fact,dtype=np.int64)
fact_inv = np.array(fact_inv,dtype=np.int64)


U = N - M
comb = fact[U] * fact_inv[:U+1] % MOD * fact_inv[U::-1] % MOD
comb[1::2] *= (-1)

P = np.zeros(R+1,dtype=np.int64)
for i,x in enumerate(comb,M):
    P[::i] += x


P[M:] -= P.copy()[:-M]
P %= MOD

# (1-x)^{N+1}で割る
Q = fact[N:N+R+1] * fact_inv[:R+1] % MOD * fact_inv[N] % MOD

def f(R):
    total = fact[R+N] * fact_inv[R] % MOD * fact_inv[N] % MOD
    x = (Q[R::-1] * P[:R+1] % MOD).sum() % MOD
    coef = fact[N] * fact_inv[M] % MOD * fact_inv[N-M] % MOD
    return (total - x*coef)%MOD

answer = (f(R) - f(L-1))%MOD
print(answer)
### BUGGY CODE ###

n = int(input())
s = list(input())
answer = n
for i in range(n):
  left_count = s[:i].count('W')
  right_count = s[i:].count('E')
  total = left_count + right_count
  answer = min(answer, total)
print(answer)

### FIXED CODE ###

n = int(input())
s = list(input())
answer = n
left_count = 0
right_count = s.count('E')
for i in range(n):
  if i != 0 and s[i-1] == 'W':
    left_count += 1
  if s[i] == 'E':
    right_count -= 1
  total = left_count + right_count
  answer = min(answer, total)
print(answer)
### BUGGY CODE ###

n = int(input())
dll =[]
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        dll.insert(0, command[1])
    elif command[0] == 'delete':
        for i in range(len(dll)):
            if dll[i] == command[1]: 
                dll.pop(i)
                break
    elif command[0] == 'deleteFirst':
        dll.pop(0)
    else:
        dll.pop()

print(*dll)

### FIXED CODE ###

from collections import deque

n = int(input())
dll = deque()
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        dll.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            dll.remove(command[1])
        except:
            pass
    elif command[0] == 'deleteFirst':
        dll.popleft()
    else:
        dll.pop()
print(*dll)
### BUGGY CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
A=[0]*(n+1)
A[0]=1
for i in range(1,n+1):
  if i in a:
    A[i]==0
  else:
    A[i]=A[i-1]+A[i-2]
print(A[n]%(10**9+7))

### FIXED CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
a=set(a)
A=[0]*(n+1)
A[0]=1
for i in range(1,n+1):
  if i in a:
    A[i]==0
  else:
    A[i]=A[i-1]+A[i-2]
print(A[n]%(10**9+7))
### BUGGY CODE ###

import math


def rank(arr):
    lastIndex = len(arr) - 1
    while lastIndex > 0:

        for i in range(lastIndex):
            if arr[i + 1] < arr[i]:
                tmp = arr[i + 1]
                arr[i + 1] = arr[i]
                arr[i] = tmp

        lastIndex = lastIndex - 1

    return arr

def half_search(arr, N, startIndex, endIndex):
    if startIndex == endIndex:
        if arr[startIndex] > N:
            return startIndex
        else:
            return -1

    if endIndex - startIndex == 1:

        if arr[startIndex] > N:
            return startIndex
        else:

            if arr[endIndex] <= N:
                return -1

            return endIndex

    m = (startIndex + endIndex) % 2

    if m == 1:
        # 偶数 2,5 => 3,4
        s1 = int((startIndex + endIndex - 1) / 2)
        s2 = s1 + 1
        value1 = arr[s1]

        if N < value1:
            return half_search(arr, N, startIndex, s2)
        else:
            return half_search(arr, N, s1, endIndex)
    else:
        # 奇数 3,6 => 5
        #
        midIndex = int((startIndex + endIndex + 1) / 2)
        midValue = arr[midIndex]

        if midValue > N:
            return half_search(arr, N, startIndex, midIndex)
        else:
            return half_search(arr, N, midIndex, endIndex)

def calculate(arr):
    if len(arr) < 3:
        return 0

    index = len(arr) - 1
    result = 0
    while index - 2 >= 0:

        s1 = arr[index] # 最大的值

        secondIndex = index - 1

        while secondIndex - 1 >= 0:

            s2 = arr[secondIndex]

            left = arr[:secondIndex]

            dirrerence = math.fabs(s2 - s1)
            t = half_search(left, dirrerence, 0, len(left) - 1)
            res = 0
            if t >= 0:
                res = len(left) - t
            result = result + res

            secondIndex = secondIndex - 1
        index = index - 1

    return result

N = input()
S = list(input().split(' '))
S = list(map(int, S))

arr = rank(S)
result = calculate(arr)
print(result)

### FIXED CODE ###

import bisect

N = int(input())

ARR = list(map(int,input().split()))

def calculate(n,arr):
    arr = sorted(arr)
    sum = 0
    for i in range(n-1):
        for j in range(i+1,n):
            mmm = arr[j] + arr[i] - 1
            nnn = bisect.bisect_right(arr,mmm)
            sum = sum + nnn - (j + 1)

    print(sum)


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

import collections

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

s1 = s[:n]
s2 = s[-1:-(n + 1):-1]

s_1 = collections.defaultdict(int)
s_2 = collections.defaultdict(int)
for i in range(2 ** n):
    bin_i = bin(i + 2 ** n)
    sequence1 = ""
    sequence1_inverse = ""
    sequence2 = ""
    sequence2_inverse = ""
    for j in range(n):
        if bin_i[j + 3] == "1":
            sequence1 += s1[j]
            sequence2 += s2[j]
        else:
            sequence1_inverse += s1[j]
            sequence2_inverse += s2[j]
    s_1[(sequence1, sequence1_inverse)] += 1     
    s_2[(sequence2, sequence2_inverse)] += 1
ans = 0
for i in dict(s_1):
    if i in dict(s_2):
        ans += dict(s_1)[i] * dict(s_2)[i]
print(ans)


### FIXED CODE ###

import collections

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

s1 = s[:n]
s2 = s[-1:-(n + 1):-1]

s_1 = collections.defaultdict(int)
s_2 = collections.defaultdict(int)

strlist = []

for i in range(2 ** n):
    bin_i = bin(i + 2 ** n)
    sequence1 = ""
    sequence1_inverse = ""
    sequence2 = ""
    sequence2_inverse = ""
    for j in range(n):
        if bin_i[j + 3] == "1":
            sequence1 += s1[j]
            sequence2 += s2[j]
        else:
            sequence1_inverse += s1[j]
            sequence2_inverse += s2[j]
    s_1[sequence1 + "-" + sequence1_inverse] += 1     
    s_2[sequence2 + "-" + sequence2_inverse] += 1
ans = 0

for i in dict(s_1):
    ans += s_1.get(i, 0) * s_2.get(i, 0)
    '''
    if i in dict(s_2):
        ans += dict(s_1)[i] * dict(s_2)[i]
    '''
print(ans)
### BUGGY CODE ###

N, A, B = map(int, input().split())
h = [int(input()) for i in range(N)]
Tmax=2*max(h)//B
def Tenabled(Tin):
    x = [h[i] for i in range(N)]
    for i in range(N):
        x[i] -= B*Tin
    S = 0
    for i in range(N):
        if x[i]>0:
            S += -((-x[i])//(A-B))
    if S<=Tin:
        return True
    else:
        return False


high=Tmax
low=0
t=(high+low)//2
while(low<=high):
    if Tenabled(t):
        high=t
    else:
        low=t+1
    t=(high+low)//2
    if Tenabled(t)==True and Tenabled(t-1)==False:
        break
print(t)


### FIXED CODE ###

N, A, B = map(int, input().split())
h = [int(input()) for i in range(N)]
Tmax=2*max(h)//B
def Tenabled(Tin):
    x = [h[i] for i in range(N)]
    for i in range(N):
        x[i] -= B*Tin
    S = 0
    for i in range(N):
        if x[i]>0:
            S += -((-x[i])//(A-B))
    if S<=Tin:
        return True
    else:
        return False


high=Tmax
low=0
t=(high+low)//2
while(low<=high):
    if Tenabled(t):
        high=t
    else:
        low=t+1
    t=(high+low)//2
    if Tenabled(t)==True and Tenabled(t-1)==False:
        break
print(t)
### BUGGY CODE ###

N=int(input())
x=[int(input()) for _ in range(N)]

#x=dict(zip(range(1,N+1),a))
#print(x)
route=[1,]
while 2 not in route:
  #print(x[route[-1]])
  if x[route[-1]-1] not in route:
    route.append(x[route[-1]-1])
  else:
    print(-1)
    exit()
print(len(route)-1)

### FIXED CODE ###

N=int(input())
x=[int(input()) for _ in range(N)]

on=1
ans=0
for _ in range(N):
  on=x[on-1]
  ans=ans+1
  if on==2:
    print(ans)
    exit()
  
print(-1)
### BUGGY CODE ###

import sys
n = int(input())
A = list(map(int, sys.stdin))

cnt = 0
def insertion_sort(L, n, g):
    global cnt
    for i in range(g, n):
        v = L[i]
        j = i - g
        while 0 <= j and v < L[j]:
            L[j+g] = L[j]
            j -= g
            cnt += 1
        L[j+g] = v


def shell_sort(L, n):
    global G
    for i in G:
        insertion_sort(L, n, i)

g = []
for i in range(100):
    x = pow(4, i)
    if n < x:
        break
    else:
        g.append(x)

G = list(reversed(g))
shell_sort(A, n)

print(len(G))
print(' '.join(str(x) for x in G))
print(cnt)
for i in A:
    print(i)

### FIXED CODE ###

import sys
n = int(input())
A = list(map(int, sys.stdin))

cnt = 0
def insertion_sort(L, n, g):
    global cnt
    for i in range(g, n):
        v = L[i]
        j = i - g
        while 0 <= j and v < L[j]:
            L[j+g] = L[j]
            j -= g
            cnt += 1
        L[j+g] = v


def shell_sort(L, n):
    global G
    for i in G:
        insertion_sort(L, n, i)

G = [i for i in [262913, 65921, 16577, 4193, 1073, 281, 77, 23, 8, 1] if i <= n]
shell_sort(A, n)

print(len(G))
print(' '.join(str(x) for x in G))
print(cnt)
for i in A:
    print(i)
### BUGGY CODE ###

mod = 10**9+7
n,m = map(int,input().split())
a = [0]*m
for i in range(m):
    a[i] = int(input())
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1) :
    dp[i] = (dp[i-1] + dp[i-2]) % mod
    if i in a :
        dp[i] = 0
print(dp[n])

### FIXED CODE ###

mod = 10**9+7
n,m = map(int,input().split())
a = set()
for i in range(m):
    a.add(int(input()))
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1) :
    dp[i] = (dp[i-1] + dp[i-2]) % mod
    if i in a :
        dp[i] = 0
print(dp[n])
### BUGGY CODE ###

from itertools import accumulate

n,k=map(int,input().split())
dp2=list(map(int,input().split()))
    
for ki in range(1,k+1):
    ims=[0]*(n+1)
    for ni in range(n):
        if 0>ni-dp2[ni]:
            ims[0]+=1
        else:
            ims[ni-dp2[ni]]+=1
        if n<ni+dp2[ni]+1:
            ims[n]-=1
        else:
            ims[ni+dp2[ni]+1]-=1

    dp2=list(accumulate(ims))
    
for i in range(n):
    print(dp2[i],end=" ")
print()


### FIXED CODE ###

n,k=map(int,input().split())
dp2=list(map(int,input().split()))
    
k=min(k,41)
for ki in range(1,k+1):
    ims=[0]*(n+1)
    for ni in range(n):
        if 0>ni-dp2[ni]:
            ims[0]+=1
        else:
            ims[ni-dp2[ni]]+=1
        if n<ni+dp2[ni]+1:
            ims[n]-=1
        else:
            ims[ni+dp2[ni]+1]-=1

    dp2[0]=ims[0]
    for ni in range(1,n):
        dp2[ni]=dp2[ni-1]+ims[ni]
    
for i in range(n):
    print(dp2[i],end=" ")
print()
### BUGGY CODE ###

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

for idx, el in enumerate(nums):
	del nums[idx]
	print(max(nums))
	nums.insert(idx, el)



### FIXED CODE ###

import numpy as np

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

num_max = np.max(nums)
next_max = sorted(nums)[-2]


for idx, el in enumerate(nums):
	if num_max == el:
		print(next_max)		
	else:
		print(num_max)
### BUGGY CODE ###

S = input()
n = 0
s = []
patern = 0
for i in range(len(S)):
    s.append(S[i])
while n < len(s):
    if s[n] is 'x':
        if s[-n-1] is not 'x':
            s.append('x')
            patern += 1
    else:
        if s[-n-1] is 'x':
            s.insert(n,'x')
            patern += 1
        elif s[-n-1] is not s[n]:
            patern = -1
            break
    n += 1
if patern != -1:
    print(patern)
else:
    print(patern)

### FIXED CODE ###

S = input()
n, m = 0, 1
s = []
patern = 0
for i in range(len(S)):
    s.append(S[i])
while n + m < len(s):
    if s[n] is 'x':
        if s[-m] is not 'x':
            s.append('x')
            patern += 1
    else:
        if s[-m] is 'x':
            n -= 1
            patern += 1
        elif s[-m] is not s[n]:
            patern = -1
            break
    n += 1
    m += 1
if patern != -1:
    print(patern)
else:
    print(patern)
### BUGGY CODE ###

import itertools
n, m = map(int, input().split())
x, y, z = [0]*n, [0]*n, [0]*n
for i in range(n):
  x[i], y[i], z[i] = map(int, input().split())
output = 0
for i in list(itertools.combinations(range(n), m)):
  r = abs(sum([x[s] for s in i])) + abs(sum([y[s] for s in i])) + \
      abs(sum([z[s] for s in i]))
  if output <= r:
    output = r
print(output)

### FIXED CODE ###

import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  ppp = []
  ppm = []
  pmp = []
  pmm = []
  mpp = []
  mpm = []
  mmp = []
  mmm = []
  for _ in range(N):
    x, y, z = map(int, input().split())
    ppp.append(x+y+z)
    ppm.append(x+y-z)
    pmp.append(x-y+z)
    pmm.append(x-y-z)
    mpp.append(-x+y+z)
    mpm.append(-x+y-z)
    mmp.append(-x-y+z)
    mmm.append(-x-y-z)
  ppp = sorted(ppp, key=lambda x:-x)
  ppm = sorted(ppm, key=lambda x:-x)
  pmp = sorted(pmp, key=lambda x:-x)
  pmm = sorted(pmm, key=lambda x:-x)
  mpp = sorted(mpp, key=lambda x:-x)
  mpm = sorted(mpm, key=lambda x:-x)
  mmp = sorted(mmp, key=lambda x:-x)
  mmm = sorted(mmm, key=lambda x:-x)

  ans = max(sum(ppp[:M]), sum(ppm[:M]), sum(pmp[:M]), sum(pmm[:M]),
            sum(mpp[:M]), sum(mpm[:M]), sum(mmp[:M]), sum(mmm[:M]))
  print(ans)


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

N = int(input())
S = input()
ans = 0
for i in range(1, N):
    cnt = 0
    for j in range(N-i):
        if S[j] == S[i+j]:
            cnt += 1
        else:
            ans = max(ans, min(cnt, i))
            cnt = 0
    ans = max(ans, min(cnt, i))
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = 0
for i in range(1, N):
    cnt = 0
    for j in range(N-i):
        if S[j] == S[i+j]:
            cnt += 1
            if cnt == i:
                ans = max(ans, i)
                break
        else:
            ans = max(ans, cnt)
            cnt = 0
    ans = max(ans, cnt)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

    ans = 0
    MOD = 10**9+7
    k = 1
    for i in range(60):
        c = 0
        for j in range(N):
            c += A[j] & 1
            A[j] >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

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

### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

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

N=int(input())
P= [list(map(int,input().split()))]
a=1

for i in range(0,len(P[0])):
    a=a*P[0][i]

if a> 10**18:
    print(-1)
else:
    print(a)
    

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort()
B=1
for i in A:
  B*=i
  if(B>10**18):
    B=-1
    break
print(B)
### BUGGY CODE ###

import numpy as np
l_input = [int(e) for e in input().split()]
N = l_input[0]
K = l_input[1]
result = [N]
for i in range(1000000000000000000000000000000):
    result.append(abs(result[i]-K))
    ans = result[i+1] in result
    if result[i+1] < K/2:
        break
print(min(result))

### FIXED CODE ###

import numpy as np
l_input = [int(e) for e in input().split()]
N = l_input[0]
K = l_input[1]
result = [N%K]
for i in range(1000000000000000000000000000000):
    result.append(abs(result[i]-K))
    ans = result[i+1] in result
    if result[i+1] < K/2:
        break
print(min(result))
### BUGGY CODE ###

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

ans = 0

for i in range(len(a)):
  for j in range(i+1, len(a)):
    ans = (a[i] * a[j]) % 1000000007 + ans % 1000000007
    
print(ans)

### FIXED CODE ###

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

ans = 0

for i in range(2,n+1):
  a[-i] += a[-i+1]

for i in range(len(a)-1):
  ans = ans % 1000000007 + ((a[i] - a[i+1]) * a[i+1]) % 1000000007
    
print(ans % 1000000007)