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

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

input()
arr = [(v, idx) for idx, v in enumerate(map(int, input().split()))]

dp = [-1 for _ in range(len(arr))]


def maximize(global_idx, temp_arr):
    if len(temp_arr) == 0:
        return 0

    # if dp[global_idx] != -1:
    #     return dp[global_idx]

    mx = 0

    for idx, child in enumerate(temp_arr):
        v, local_idx = child
        mx = max(mx, abs(global_idx - local_idx) * v + maximize(global_idx + 1, temp_arr[:idx] + temp_arr[idx + 1:]))

    dp[global_idx] = mx
    return dp[global_idx]


print(maximize(0, arr[:]))


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 9)

input()

arr = list(sorted([(v, idx) for idx, v in enumerate(map(int, input().split()))], reverse=True))

d = [[-1 for _ in range(len(arr))] for _ in range(len(arr))]


def dp(l, r, idx):
    if idx == len(arr):
        return 0

    if d[l][r] != -1:
        return d[l][r]

    left = abs(arr[idx][1] - l) * arr[idx][0] + dp(l + 1, r, idx + 1)
    right = abs(arr[idx][1] - r) * arr[idx][0] + dp(l, r - 1, idx + 1)

    d[l][r] = max(left, right)
    return max(left, right)


print(dp(0, len(arr) - 1, 0))
### BUGGY CODE ###

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

a=sorted(a)
for ia in a:
  print(c.index(ia)+1, end=' ')

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[x for x in range(n)]
for i in range(n):
  ans[(a[i] - 1)] = i + 1
for aaa in ans:
  print(aaa)
### BUGGY CODE ###

def dijkstra(s,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

def dis(p,q):
    cand = ((x[p]-x[q])**2+(y[p]-y[q])**2)**0.5 - r[p] - r[q]
    return max(cand,0)
    

Xs,Ys,Xt,Yt = map(int,input().split())
n = int(input())
x = [0]*(n+2)
y = [0]*(n+2)
r = [0]*(n+2)
x[0] = Xs
y[0] = Ys
x[1] = Xt
y[1] = Yt
for i in range(2,n+2):
    x[i],y[i],r[i] = map(int,input().split())
edge = [[0]*(n+2)for i in range(n+2)]

for i in range(n+2):
    for j in range(i,n+2):
        edge[i][j] = dis(i,j)
        edge[j][i] = dis(i,j)
n += 2
res = dijkstra(0,edge)
print(res[1])

### FIXED CODE ###

Xs,Ys,Xt,Yt = map(int,input().split())
n = int(input())
p = [(Xs,Ys,0),(Xt,Yt,0)]
for i in range(2,n+2):
    p.append(tuple(map(int,input().split())))
cost = [[0]*(n+2)for i in range(n+2)]

for i in range(n+2):
    for j in range(i,n+2):
        cost[i][j] = cost[j][i] =  max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0)
n += 2
s = 0
#始点sから各頂点への最短距離
#n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
d = [float("inf")] * n
used = [False] * n
d[s] = 0
    
while True:
    v = -1
    #まだ使われてない頂点の中から最小の距離のものを探す
    for i in range(n):
        if (not used[i]) and (v == -1):
           v = i
        elif (not used[i]) and d[i] < d[v]:
            v = i
    if v == -1:
           break
    used[v] = True
           
    for j in range(n):
           d[j] = min(d[j],d[v]+cost[v][j])
print(d[1])
### BUGGY CODE ###

N,K = list(map(int, (input().split())))
A = list(map(int, (input().split())))
scorerange = N-K
for semester in range(scorerange):
    recent = A[semester:semester+K+1]
    if (recent[0]<recent[-1]):
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N,K = list(map(int, (input().split())))
A = list(map(int, (input().split())))
scorerange = N-K
for semester in range(scorerange):
    if (A[semester]<A[semester+K]):
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import numpy as np

s = input()
K = int(s)

if ((K & 1 == 0) or (int(s[-1]) % 5 == 0)):
  print(-1)

if K % 7 == 0:
  L = 9 * K / 7
else:
  L = 9 * K

i = 1
r = 10
while True:
  r = r % L
  if r == 1:
    print(i)
    break
  r *= 10
  i += 1

### FIXED CODE ###

s = input()
K = int(s)

if ((K & 1 == 0) or (s[-1] == "5")):
  print(-1)
else:
  if K % 7 == 0:
    L = 9 * K / 7
  else:
    L = 9 * K

  i = 1
  r = 10
  while True:
    r = r % L
    if r == 1:
      print(i)
      break
    r *= 10
    i += 1
### BUGGY CODE ###

K, S = [int(n) for n in input().split(' ')]

ans = 0
for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            if (X+Y+Z)==S:
                ans += 1
print(ans)


### FIXED CODE ###

K, S = [int(n) for n in input().split(' ')]

ans = 0

for x in range(0,K+1):
    for y in range(0,K+1):
        z = S - x - y
        if z >= 0 and z <= K:
            ans += 1
print(ans)
### BUGGY CODE ###

n,k = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9+7
# s=正の数、t=負の数
s,t = [], []
for a in A:
  if a<0:
    t.append(a)
  else:
    s.append(a)

S = len(s)
T = len(t)
ok = False
if (S>0):
  if n==k:
    # すべての負の数をペアにできる
    ok = T%2==0
  else:
    # 負の数は考慮しない
    ok = True
else:
  # kが偶数個
  ok = (k%2==0)

ans = 1
if not ok:
  A.sort(key=lambda x: abs(x))
  for i in range(k):
    ans *= A[i]
else:
  s.sort()
  t.sort(reverse=True)
  if k%2==1:
    ans *= s.pop()

  p = []
  while len(s) >= 2:
    x = s.pop()
    x *= s.pop()
    p.append(x)

  while len(t) >= 2:
    x = t.pop()
    x *= t.pop()
    p.append(x)

  p.sort(reverse=True)
  for i in range(k//2):
    ans *= p[i]

print(ans % MOD)

### FIXED CODE ###

n,k = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9+7
# s=正の数、t=負の数
s,t = [], []
for a in A:
  if a<0:
    t.append(a)
  else:
    s.append(a)

S = len(s)
T = len(t)
ok = False
if (S>0):
  if n==k:
    # すべての負の数をペアにできる
    ok = T%2==0
  else:
    # 負の数は考慮しない
    ok = True
else:
  # kが偶数個
  ok = (k%2==0)

ans = 1
if not ok:
  A.sort(key=lambda x: abs(x))
  for i in range(k):
    ans *= A[i]
    ans %= MOD
else:
  s.sort()
  t.sort(reverse=True)
  if k%2==1:
    ans *= s.pop()
    ans %= MOD

  p = []
  while len(s) >= 2:
    x = s.pop()
    x *= s.pop()
    p.append(x)

  while len(t) >= 2:
    x = t.pop()
    x *= t.pop()
    p.append(x)

  p.sort(reverse=True)
  for i in range(k//2):
    ans *= p[i]
    ans %= MOD

print(ans % MOD)
### BUGGY CODE ###

n = int(input())
h = [int(i) for i in input().split()]

flag = 1
while(flag==1):
    for i in range(len(h)-1):
        if(h[i+1]<h[i]):
            h[i] -= 1
            for j in range(i+1,len(h)):
                if(h[j]<h[i]):
                    print("No")
                    flag=0
                    break
        if(flag==0):
            break
            
    if(flag==1):
        print("Yes")
        break

### FIXED CODE ###

n = int(input())
h = [int(i) for i in input().split()]

flag = 1
temp = h[0]
for i in range(len(h)-1):
    if(temp<h[i]):
        temp = h[i]
    if(temp-h[i+1]>=2):
        print("No")
        flag=0
        break
            
if(flag==1):
    print("Yes")
### BUGGY CODE ###

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

sum_tmp = [sum(arr[i:i+k]) for i in range(n - (k - 1))]
max_v = max(sum_tmp)
max_i = sum_tmp.index(max_v)
ans = 0
for j in arr[max_i:max_i+k]:
    ans += sum(range(1, j+1)) / j
print(ans)

### FIXED CODE ###

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

m = sum(arr[0:k])
sump = m

for i in range(1, n-k+1):
    sump = sump - arr[i-1] + arr[i+k-1]
    if m < sump:
        m = sump

ans = (m + k) / 2

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

n = int(input())

boss_nums = input()
boss_nums = boss_nums.split()

subordinate = []

for boss in range(1, n+1):
    count = 0

    for num in boss_nums:
        if int(num) == boss:
            count = count + 1

    subordinate.append(count)


for num in range(0, n):
    print(subordinate[num])



### FIXED CODE ###

n = int(input())

boss_nums = input()
boss_nums = boss_nums.split()

subordinate = [0] * n

for num in boss_nums:
    num = int(num)
    subordinate[num-1] += 1


for num in range(0, n):
    print(subordinate[num])
### BUGGY CODE ###

# 有効グラフ上で、近道に当たる点はすべて余計な辺
# ある点に入ってくる最も距離が長い辺のみが有効となる
# ある頂点に対して入ってきた辺の(cost, 入力元)を持っておき、
# さらに距離の長い辺がやってきたら(cost, 入力元)で置き換える
# 最後に残ったものを出力する
# 入力のあった頂点を記録することで、入力の無かった頂点を根とみなせる

import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
G = [[] for i in range(N)]
grandparent = set(range(N))
for i in range(N - 1 + M):
  a,b = map(int,readline().split())
  G[a-1].append(b-1)
  grandparent -= {b - 1}

start = list(grandparent)[0]
from collections import deque

longest = [(-1,-1) for i in range(N)]
# longest[頂点] =  (コスト, 入力元)
longest[start] = (0, -1)

# 頂点, コスト, 入力元
q = deque([(start, 0, -1)])
while q:
  v, dist, parent = q.popleft()
  if longest[v][0] > dist:
    continue
  longest[v] = (dist, parent)
  for child in G[v]:
    q.append((child, dist + 1, v))
  
for g in longest:
  print(g[1] + 1)

### FIXED CODE ###

# トポロジカルソート

import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
G = [[] for i in range(N)]
revG = [[] for i in range(N)]
# ある頂点に対する入次数を記録
indegree = [0 for i in range(N)]

for i in range(N - 1 + M):
  u,v = map(int,readline().split())
  G[u - 1].append(v - 1)
  revG[v - 1].append(u - 1)
  indegree[v - 1] += 1

# トポロジカルソートを格納する
res = []

# 入り次数が0になった頂点を高速に発見するため、隣接する頂点をキューで管理
from collections import deque
q = deque()
for i in range(len(indegree)):
  if indegree[i] == 0:
    q.append(i)

while q:
  # キューの先頭の頂点を取り出す
  v = q.popleft()
  
  # その頂点と隣接する頂点の入次数を減らし、0になったらキューに追加
  for child in G[v]:
    indegree[child] -= 1
    if indegree[child] == 0:
      q.append(child)
      
  # 入り次数が0で且つ隣接する頂点が処理済みとなった頂点をソート配列に追加する
  res.append(v)
  
# インデックスと頂点番号を逆転させたものを作成する
inds = [-1 for i in range(N)]
for i in range(len(res)):
  inds[res[i]] = i
  
# print(inds)
for i in range(len(revG)):
  ans = -1
  maxv = -1
  for parent in revG[i]:
#    print("i",i,"に対する親",parent)
    if inds[parent] > maxv:
      maxv = inds[parent]
      ans = parent
  print(ans + 1)
### BUGGY CODE ###

from functools import lru_cache
import sys
from collections import deque
sys.setrecursionlimit(1000000)
	
sorted_a = ""
m = dict({})

def dist_a(a):
	res = 0
	for i, x in enumerate(a):
		res += abs(i - int(x))
	return res

N = int(input())
A = ''.join(list(map(lambda x: str(int(x)-1), input().split())))
sorted_a = ''.join(list(sorted(A)))
#i = 1
#j = 4
#x = "03214"
#print(A[:i:])
#print(A[::-1][len(A)-j:len(A)-i:])
#print(A[j::])
#print(x[:i:] + x[::-1][len(x)-j:len(x)-i:] + x[j::])
q = deque()
q.append((A, 0))
m[A] = 0
while True:
	a, x = q.popleft()
	if a in m and m[a] < x:
		continue
	#if x == 4:
	#	break;
	#print(len(m))
	if a == sorted_a:
		print(x)
		break
	d_a = dist_a(a)
	for i in range(len(a)):
		for j in range(i+2, len(a)+1):
			next_a = a[:i:] + a[::-1][len(a)-j:len(a)-i:] + a[j::]
			if next_a in m:
				continue
			if d_a < dist_a(next_a):
				continue
			q.append((next_a, x+1))
			m[next_a] = x+1
			
	
#print(reverse_a(A, 0))




### FIXED CODE ###

from functools import lru_cache
import sys
from collections import deque
sys.setrecursionlimit(1000000)
	
sorted_a = ""
m = dict({})

N = int(input())
A = ''.join(list(map(lambda x: str(int(x)-1), input().split())))
sorted_a = ''.join(list(sorted(A)))

q = deque()
q.append((A, 0))
m[A] = 0
while True:
	a, x = q.popleft()
	if a in m and m[a] < x:
		continue
	if x == (len(a)-1) // 2:
		break;

	for i in range(len(a)):
		for j in range(i+2, len(a)+1):
			next_a = a[:i:] + a[::-1][len(a)-j:len(a)-i:] + a[j::]
			if next_a in m:
				continue

			q.append((next_a, x+1))
			m[next_a] = x+1
			
m2 = dict({})
q = deque()
q.append((sorted_a, 0))
m2[sorted_a] = 0
while True:
	a, x = q.popleft()
	if a in m2 and m2[a] < x:
		continue
	if x == (len(a)-1) // 2:
		break;

	for i in range(len(a)):
		for j in range(i+2, len(a)+1):
			next_a = a[:i:] + a[::-1][len(a)-j:len(a)-i:] + a[j::]
			if next_a in m2:
				continue
			q.append((next_a, x+1))
			m2[next_a] = x+1

ret = sys.maxsize
for a, x in m.items():
	if a in m2:
		ret = min(ret, x + m2[a])
	
if ret == sys.maxsize:
	print(len(A) - 1)
else:
	print(ret)
### BUGGY CODE ###

s=input()
t=input()
S=[]
c=0
for i in range(len(s)):
    if s[i] in t:
        p=len(t)-1
        Q=[z for z, x in enumerate(t) if x == s[i]]
        for q in Q:
            if q>i or i-q+p+1>len(s):
                pass
            else:
                s1=s[i-q:i+p-q+1]
                c+=1
                count=0
                for j in range(len(s1)):
                    if s1[j]!=t[j]:
                        count+=1
                    
                    else:
                        pass
                S.append(count)
        else:
            pass
if c==0:
    print(len(t))
else:
    print(min(S))

### FIXED CODE ###

S = input()
T = input()

ans = 1000000  # 適当に1001以上を初期値にしておきます

# Tが1文字のときlen(S)回、2文字のときlen(S) - 1回 …… なので、
# len(S) - len(T) + 1 回です
for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]  # Sのi文字目から連続するlen(T)文字を、Uとします
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

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

N, K = map(int, input().split())
As = sorted(map(int, input().split()))

def check(t, As):
    "if the number of the pairs (i, j) that satisfies Ai * Aj <= t is < K, return True"
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            #index = bisect_right(As, t//A, lo = i+1) - (i+1)
            l = i
            r = N
            while r - l > 1:
                mid = (l + r) // 2
                if As[mid] <= t//A:
                    l = mid
                else:
                    r = mid
            index = r - (i+1)
        elif A < 0:
            #index = N - bisect_left(As, -((-t)//A), lo = i+1)
            l = i
            r = N
            while r - l > 1:
                mid = (l + r) // 2
                if As[mid] < -((-t)//A):
                    l = mid
                else:
                    r = mid
            index = N - r
        else:
            if t < 0:
                index = 0
            else:
                index = N - i - 1
        count += index
    return (count < K)
        

l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while r - l > 1:
    mid = (l + r) // 2
    if check(mid, As):
        l = mid
    else:
        r = mid

print(r)

### FIXED CODE ###

from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
As = sorted(map(int, input().split()))
        
l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while True:
    mid = (l + r) // 2
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            count += bisect_right(As, mid//A, lo = i+1) - (i+1)
        elif A < 0:
            count += N - bisect_left(As, -((-mid)//A), lo = i+1)
        else:
            if mid >= 0:
                count += N - i - 1
    if count < K:
        l = mid
    else:
        r = mid
    if r - l == 1:
        break

print(r)
### BUGGY CODE ###

from collections import deque
h, w = map(int, input().split())
c_h, c_w = map(int, input().split())
d_h, d_w = map(int, input().split())
#スタートとゴールの座標を設定
start_h = c_h - 1
start_w = c_w - 1
goal_h = d_h - 1
goal_w = d_w - 1
#迷路の読み込み
maze = [input() for _ in range(h)]
inf = float("inf")
dist = [[inf] * w for _ in range(h)]



def bfs(x, y):
    dist[x][y] = 0
    q = deque()
    q.append((x, y))
    while q:
        x, y = q.popleft() 
        d = dist[x][y]
        for dx, dy in [(0,1),(1,0),(0,-1),(-1,0)]:
            nx = x + dx
            ny = y + dy 
            if not 0 <= nx < h or not 0 <= ny < w:
                continue
            if maze[nx][ny] == "#":
                continue
            if dist[nx][ny] <= d:
                continue
            dist[nx][ny] = d           
            q.appendleft((nx, ny))

        for dxx in range(-2, 3):
            for dyy in range(-2, 3):
                 nxx = x + dxx
                 nyy = y + dyy 
                 if not 0 <= nxx < h or not 0 <= nyy < w:
                    continue
                 if maze[nxx][nyy] == "#":
                    continue
                 if dist[nxx][nyy] <= d+1:
                    continue
                 dist[nxx][nyy] = d+1
                 q.append((nxx, nyy))
                



bfs(start_h, start_w)
if dist[goal_h][goal_w] == inf:
    print("-1")
else:
    print(dist[goal_h][goal_w])    

### FIXED CODE ###

from collections import deque
h, w = map(int, input().split())
c_h, c_w = map(int, input().split())
d_h, d_w = map(int, input().split())
#スタートとゴールの座標を設定
start_h = c_h - 1
start_w = c_w - 1
goal_h = d_h - 1
goal_w = d_w - 1
#迷路の読み込み
maze = [input() for _ in range(h)]
inf = float("inf")
dist = [[inf] * w for _ in range(h)]



def bfs(x, y):
    dist[x][y] = 0
    q = deque()
    q.append((x, y))
    while q:
        x, y = q.popleft() 
        d = dist[x][y]
        for dx, dy in [(0,1),(1,0),(0,-1),(-1,0)]:
            nx = x + dx
            ny = y + dy 
            if not 0 <= nx < h or not 0 <= ny < w:
                continue
            if maze[nx][ny] == "#":
                continue
            if dist[nx][ny] <= d:
                continue
            dist[nx][ny] = d           
            q.appendleft((nx, ny))

        for dxx in range(-2, 3):
            for dyy in range(-2, 3):
                 nxx = x + dxx
                 nyy = y + dyy 
                 if not 0 <= nxx < h or not 0 <= nyy < w:
                    continue
                 if maze[nxx][nyy] == "#":
                    continue
                 if dist[nxx][nyy] <= d+1:
                    continue
                 dist[nxx][nyy] = d+1
                 q.append((nxx, nyy))
                



bfs(start_h, start_w)
if dist[goal_h][goal_w] == inf:
    print("-1")
else:
    print(dist[goal_h][goal_w])
### BUGGY CODE ###

def main():
    n = int(input())
    vals = list(map(int, input().split()))
    flg = 0
    for i in vals:
        if vals.count(i) > 1:
            flg += 1
            break
    if flg == 0:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    vals = list(map(int, input().split()))
    flg = 0

    vals.sort()
    for i in range(n-1):
        if vals[i] == vals[i + 1]:
            flg += 1
            break
    if flg == 0:
        print('YES')
    else:
        print('NO')


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

# -*- coding: utf-8 -*-
from operator import itemgetter

N, M, Q = map(int, input().split())

LRi = []
for i in range(M):
    L, R = map(int, input().split())
    LRi.append((L,R))


LRi.sort(key=itemgetter(1))

pqi = []
for i in range(Q):
    p, q = map(int, input().split())
    pqi.append((p,q))

# pqi.sort(key=itemgetter(1))

#
# print(LRi)
# print(pqi)

for (p, q) in pqi:
    cnt = 0
    for (L,R) in LRi:
        if p <= L and R <= q:
            cnt += 1
        elif q < R:
            break
    print(cnt)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# import numpy as np

N, M, Q = map(int, input().split())

# Xi = np.zeros((N+1,N+1),dtype=np.int32)
Xi = [[0]*(N+1) for i in range(N+1)]
for i in range(M):
    L, R = map(int, input().split())
    Xi[L][R] += 1

# Ci = np.zeros((N+1,N+1),dtype=np.int32)
Ci = [[0]*(N+1) for i in range(N+1)]
tmp = 0
for l in range(N+1):
    for r in range(N+1):
        tmp += Xi[l][r]
        Ci[l][r] = tmp

# print(Ci)

for r in range(N+1):
    tmp = 0
    for l in range(N+1):
        tmp += Ci[l][r]
        Ci[l][r] = tmp

# print(Ci)

pqi = []
for i in range(Q):
    p, q = map(int, input().split())
    pqi.append((p,q))

for (p, q) in pqi:
    tmp = Ci[q][q] - Ci[q][p-1]  - Ci[p-1][q] + Ci[p-1][p-1]
    print(tmp)
### BUGGY CODE ###

from bisect import*
from numpy import*
n=int(input())
a,b=eval('int64(input().split()),'*2)
c=0
for k in range(28,-1,-1):
    l,h=2**k,2**-~k
    a%=h
    b=sort(b%h)
    m=0
    for t in a:
        if l-t<0:
            i=bisect_left(b,(l-t)%h)-n
        else:
            i=bisect_left(b,l-t)
        j=bisect_left(b,h-t)
        m+=j-i
    c+=m%2*2**k
print(c)

### FIXED CODE ###

def main():
    from numpy import array,searchsorted,sum,hstack
    n,*t=map(int,open(0).read().split())
    a,b=array(t[:n],'i4'),array(t[n:],'i4')
    c=0
    for k in range(28,-1,-1):
        l,h=pow(2,k),pow(2,k+1)
        a%=h
        b%=h
        b.sort()
        y=hstack((b-h,b))
        i=searchsorted(y,l-a)
        j=searchsorted(y,h-a)
        m=sum(j-i)
        c+=m%2*l
    print(c)
if __name__=='__main__':
    main()
### BUGGY CODE ###

S = input()
SS = S
while SS.find('01') >= 0 or SS.find('10') >= 0:
    SS = SS.replace('01', '').replace('10', '')
    SS = SS.replace('10', '').replace('01', '')

print(len(S) - len(SS))

### FIXED CODE ###

S = input()
lst1 = sum([1 for x in S if x == '1'])
lst2 = sum([1 for x in S if x == '0'])
print(min(lst1, lst2) * 2)
### BUGGY CODE ###

S = input()

T = [s if s != "?" else "0" for s in S]
T = int(''.join(T))
SS = T % 13

c = {}
for i in range(len(S)):
    if S[len(S) - i - 1] != "?":
        continue
    tc = {i: 0 for i in range(13)}
    for j in range(0, 10):
        t = j * 10 ** i
        tc[t % 13] += 1
    c[i] = tc

dp = []
tdp = {i: 0 for i in range(13)}
tdp[SS] += 1
dp.append(tdp)
for k, v in c.items():
    tdp = {i: 0 for i in range(13)}
    for r, c in v.items():
        for _r, _v in dp[-1].items():
            tdp[(_r + r) % 13] += _v * c
    dp.append(tdp)

ans = dp[-1][5]
print(ans % (10**9 + 7))


### FIXED CODE ###

S = input()
con = 10**9 + 7

T = [s if s != "?" else "0" for s in S]
T = int(''.join(T))
SS = T % 13

def get_mod(S):
    c = {}
    iii = 1
    for i in range(len(S)):
        if S[len(S) - i - 1] != "?":
            iii *= 10
            iii %= 13
            continue
        c[i] = {(j * iii) % 13: 1 for j in range(0, 10)}
        iii *= 10
        iii %= 13
    return c
c = get_mod(S)

def get_tdp(pdp):
    tdp = {i: 0 for i in range(13)}
    for r in v.keys():
        for _r, _v in pdp.items():
            tdp[(_r + r) % 13] += _v
    for i in range(13):
        tdp[i] %= con
    return tdp

pdp = {i: 0 for i in range(13)}
pdp[SS] += 1
for k, v in c.items():
    pdp = get_tdp(pdp)

ans = pdp[5]
print(ans)
### BUGGY CODE ###

(n, x) = map(int, input().split())
while True:
    if n == 0 and x == 0:
        break
    c = 0
    for i in range(1,n-1):
        for j in range(i,n):
            for k in range(j, n+1):
                s = i + j + k
                if s == x:
                    c += 1
                if s > x:
                    break
            if s > x:
                break
        if s > x:
            break
    print(c)

### FIXED CODE ###

while True:
    (n, x) = map(int, input().split())
    if n == 0 and x == 0:
        break
    c = 0
    for i in range(1,n - 1):
        xi = x - i
        for j in range(i+1,n):
            if xi - j - j <= 0:
                break
            if xi - j <= n:
                c += 1
    print(c)
### BUGGY CODE ###

n,k=map(int, input().split())
a=[list(map(int, input().split())) for i in range(n)]
a.sort()
#print(a)
b=[]
for i,j in a:
    b=b+[i]*j
    if len(b)>k:break
print(b[k-1])

### FIXED CODE ###

n,k=map(int, input().split())
a=[list(map(int, input().split())) for i in range(n)]
a.sort()
#print(a)
b=[]
c=0
for i,j in a:
    k-=j
    c=i
    if k<=0: break
print(c)
### BUGGY CODE ###

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

answer=1
for i in range(n):
  answer=answer*a[i]
  
if answer>10**18:
  print(-1)
else:
  print(answer)

### FIXED CODE ###

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

b1=1
b2=0
b3=0

if 0 in a:
  print(0)
else:
  for i in range(n):
    b1*=a[i]
    b2*=a[i]
    if b1>=10**9:
      b2+=b1//(10**9)
      b1%=10**9
    if b2>=10**9:
      b3+=b2//(10**9)
      b2%=10**9
      break
  
  if b3>=1 and (b1!=0 or b2!=0):
    print(-1)
  else:
    print(b3*(10**18)+b2*(10**9)+b1)