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

N = int(input())
S = list(input())
dp = [[0]*N for _ in range(N)]
dp[N-1][N-1] = 1
for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[N-1][i] = 1

for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[i][N-1] = 1

for i in range(N-1, 0, -1):
  for j in range(N-1, 0, -1):
    if S[i-1] == S[j-1]:
      dp[i-1][j-1] = dp[i][j] + 1

ans = 0
for i in range(N):
  for j in range(i+1, N):
    ans = max(ans, min(dp[i][j], j-i))
print(ans)

### FIXED CODE ###

N = int(input())
S = list(input())
dp = [[0]*N for _ in range(N)]
dp[N-1][N-1] = 1
for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[N-1][i] = 1

for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[i][N-1] = 1

for i in range(N-1, 0, -1):
  for j in range(N-1, 0, -1):
    if S[i-1] == S[j-1]:
      dp[i-1][j-1] = dp[i][j] + 1

ans = 0
for i in range(N):
  for j in range(i+1, N):
    ans = max(ans, min(dp[i][j], j-i))
print(ans)
### BUGGY CODE ###

import math
x,y=map(int,input().split())
if (x+y)%3!=0 or 2*x<y or 2*y<x:
    print(0)
else:
    a=(2*y-x)//3
    b=(2*x-y)//3
    print(math.factorial(a+b)//(math.factorial(a)*math.factorial(b))%(10**9+7))


### FIXED CODE ###

def ncr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= numerator[k]
            if result >10**9+7:
                result = result%(10**9+7)
    return result
x,y=map(int,input().split())
if (x+y)%3!=0 or 2*x<y or 2*y<x:
    print(0)
else:
    a=(2*y-x)//3
    b=(2*x-y)//3
    print(int(ncr(a+b,a)%(10**9+7)))
### BUGGY CODE ###

n,m=map(int,input().split())
for i in range(n,m+1):
  if m%i==0:
    print(m//i)
    exit()
print(1)

### FIXED CODE ###

n,m=map(int,input().split())
for i in range(2,m):
  if i*i>m:
    print(1)
    exit()
  if m%i==0:
    break
for i in range(n,m+1):
  if m%i==0:
    print(m//i)
    exit()
### BUGGY CODE ###

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

k_y = [1000]

for i in range(n):
	genkin_list = [ hk * a[i] + hy for hk,hy in enumerate(k_y) ]  #所持株、金
	genkin_list_max = max(genkin_list)
	max_index = genkin_list.index(genkin_list_max)
	
	k_y = [ a[i]*(max_index-hk)+k_y[max_index] for hk,hy in enumerate(k_y) ]
	k_y2 = [ genkin_list_max - a[i] * x for x in range( len(k_y), genkin_list_max // a[i]+1 ) ]
	k_y = k_y + k_y2
print( k_y[0] )


### FIXED CODE ###

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

k_y = [1000]
yen = 1000
resyen = 1000
kabu_max = 0
for i in range(n):
	#株を売り払うケース
	newyen = max( yen, kabu_max * a[i] + resyen)
	
	#株を最大買うケース
	kabu_max_new = max( kabu_max + resyen // a[i], yen // a[i] )
	if kabu_max_new == yen // a[i]:
		if kabu_max_new == kabu_max + resyen // a[i]:
			resyen = max( yen % a[i], resyen % a[i])
		else:
			resyen = yen % a[i]
	
	yen = newyen
	kabu_max = kabu_max_new
	#print(kabu_max,yen,resyen)
print( yen )
### BUGGY CODE ###

N = int(input())
li = list(map(int, input().split()))
a = []
b = 0
for i in li:
  a.append(i)
  c = max(a)
  if i < c:
    b = b + c - i
print(b)
    

### FIXED CODE ###

N = int(input())
li = list(map(int, input().split()))
a = 0
b = 0
for i in li:
  if a < i:
    a = i
  if i < a:
    b = b + a - i
print(b)
### BUGGY CODE ###

import numpy as np
N,K = map(int, input().split())

S = []
for i in range(K):
    L,R = map(int, input().split())
    S.append((L,R))
S = sorted(S)

step = np.zeros(N+1)
step[1] = 1

for j in range(1,N):
    for l,r in S:
        if j + l > N:
            continue
        r_ = min(j+r+1,N+1)
        step[j+l: r_] += step[j]
        step[j+l:r_] %= 998244353
    
print(int(step[N]))

### FIXED CODE ###

mod = 998244353
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(k)]
for i in range(k):
    lr[i][1] += 1

dp = [0]*n
dp[0] = 1
for i in range(1,n):
    dp[i] = dp[i-1]
    if i == 1:
        dp[1] = 0
    for l,r in lr:
        if i - l >= 0:
            dp[i] += dp[i-l]
        if i - r >= 0:
            dp[i] -= dp[i-r]
        dp[i] %= mod
print(dp[n-1])
### BUGGY CODE ###

MAX_SPEED = 30
while True:
    N, M = map(int, input().split())
    if not (N | M):
        break
    S, G = map(lambda x: int(x) - 1, input().split())
    edge = []
    for _ in range(M):
        x, y, d, c = map(int, input().split())
        edge.append((x - 1, y - 1, d, c))
        edge.append((y - 1, x - 1, d, c))
    INF = float('inf')
    dist = [[[INF for _ in range(N)] for _ in range(MAX_SPEED + 1)] for _ in range(N)]
    dist[S][0][S] = 0.0
    while True:
        flag = False
        for x, y, d, c in edge:
            for j in range(min(MAX_SPEED + 1, c + 2)):
                for k in range(N):
                    if k == y or (j <= c and dist[x][j][k] == INF):
                        continue
                    # print(x, y, d, c, j, k, dist[x][j][k])
                    if j > 1 and dist[y][j - 1][x] > dist[x][j][k] + d / (j - 1):
                        dist[y][j - 1][x] = dist[x][j][k] + d / (j - 1)
                        flag = True
                    if 0 < j <= c and dist[y][j][x] > dist[x][j][k] + d / j:
                        dist[y][j][x] = dist[x][j][k] + d / j
                        flag = True
                    if j < c and dist[y][j + 1][x] > dist[x][j][k] + d / (j + 1):
                        dist[y][j + 1][x] = dist[x][j][k] + d / (j + 1)
                        flag = True
        if not flag:
            break
    """
    for i in range(N):
        print(*dist[i], sep='\n')
        print()
    """
    ans = min(dist[G][1][j] for j in range(N))
    print("unreachable" if ans == INF else "{:.20f}".format(ans))

### FIXED CODE ###

import sys
import heapq
if sys.version[0] == '2':
    range, input = xrange, raw_input
MAX_SPEED = 30
dvs = (-1, 0, 1)
while True:
    N, M = map(int, input().split())
    if not (N | M):
        break
    S, G = map(lambda x: int(x) - 1, input().split())
    edge = [[] for _ in range(N)]
    for _ in range(M):
        x, y, d, c = map(int, input().split())
        edge[x - 1].append((y - 1, d, c))
        edge[y - 1].append((x - 1, d, c))
    INF = 1e9
    dist = [[[INF for _ in range(N)] for _ in range(MAX_SPEED + 1)] for _ in range(N)]
    que = [(0.0, S, 0, S)]
    while que:
        cost, now, v, prev = heapq.heappop(que)
        if cost > dist[now][v][prev]:
            continue
        if now == G and v == 1:
            print("{:.20f}".format(cost))
            break
        dist[now][v][prev] = cost
        for x, d, c in edge[now]:
            if x == prev:
                continue
            for dv in dvs:
                nv = v + dv
                if 0 < nv <= c and dist[x][nv][now] > dist[now][v][prev] + d / nv:
                    dist[x][nv][now] = dist[now][v][prev] + d / nv
                    heapq.heappush(que, (dist[x][nv][now], x, nv, now))
    else:
        print("unreachable")
### BUGGY CODE ###

def main():
    from bisect import bisect_right

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

    def calc(x):
        tmp = 0
        for a in A:
            tmp += N - bisect_right(A, x - a - 0.5)
        return tmp

    l = 0
    r = 3 * 10 ** 5
    while r - l > 1:
        mid = (l + r) // 2
        if calc(mid) >= M:
            l = mid
        else:
            r = mid

    B = [0] * (N + 1)
    for i in range(N):
        B[i + 1] = B[i] + A[i]

    ans = 0
    for a in A:
        tmp = bisect_right(A, r - a - 0.5)
        M -= (N - tmp)
        ans += a * (N - tmp) + (B[-1] - B[tmp])

    ans += M * l
    print (ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from bisect import bisect_right

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

def calc(m): #m以下の組が何通りあるかを数える
    count = 0 #組数を数える
    for a in A:
        b = m - a #b以上のは含める
        count += N - bisect_right(A, b - 0.5)
    return count

l = 0 
r = 3 * 10 ** 5

while r - l > 1:
    mid = (l + r) // 2
    if calc(mid) >= M: #合計mid以上の組と手を繋ぐとしたとき、とM回以上握手できる
        l = mid
    else:
        r = mid

B = [0] * (N + 1)
for i in range(N):
    B[i + 1] = B[i] + A[i]

# print(B)
flag = False
for i in range(mid + 3, -1, -1):
    if calc(i) < M:
        flag = False
    else: #初めて手をにぎる回数がM回を下回ったとき
        break

i += 1 #合計この値までは全て使う、残り回数を調整
ans = 0
for a in A:
    b = i - a
    tmp = bisect_right(A, b - 0.5)
    M -= (N - tmp) #使った数
    ans += a * (N - tmp) + (B[-1] - B[tmp])

ans += M * (i - 1)
print (ans)
### BUGGY CODE ###

import copy

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

for n in range(N):
    B = copy.deepcopy(A)
    del B[n]
    print(max(B))

### FIXED CODE ###

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

max_A = sorted(A)[-1]
second_A = sorted(A)[-2]

for n in range(N):
    if A[n] != max_A:
        print(max_A)
    else:
        print(second_A)
### BUGGY CODE ###

#57 ABC137E
#ベルマンフォード

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

abc=[list(map(int,input().split())) for _ in range(m)]
abc=[[a,b,p-c] for a,b,c in abc]
def BF(edges,num_v,source):
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0
  
    #辺の緩和
    neg=[False for _ in range(num_v)]
    for i in range(num_v-1):
        for edge in edges:
            if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
    for i in range(num_v):
        for edge in edges:
            if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                neg[edge[1]-1]=True
            if neg[edge[0]-1]==True:
                neg[edge[1]-1]=True
    return dist,neg
dis,neg=BF(abc,n,1)
print(-1 if neg[-1] else max(0,-dis[-1]))

### FIXED CODE ###

#57 ABC137E
#ベルマンフォード

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

abc=[list(map(int,input().split())) for _ in range(m)]
abc=[[a,b,p-c] for a,b,c in abc]
def BF(edges,num_v,source):
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0
  
    #辺の緩和
    neg=[False for _ in range(num_v)]
    for i in range(num_v-1):
        for edge in edges:
            if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
    for i in range(num_v):
        for edge in edges:
            if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                neg[edge[1]-1]=True
            if neg[edge[0]-1]==True:
                neg[edge[1]-1]=True
    return dist,neg
dis,neg=BF(abc,n,1)
#print(dis,neg)
print(-1 if neg[-1] else max(0,-dis[-1]))
### BUGGY CODE ###


s=input()
q=int(input())
n=0
for i in range(q):
    l=input().split()
    if l[0]=='1':
        n+=1
    else:
        if (l[1]=='1' and n%2==0) or (l[1]=='2' and n%2==1):
            s=l[2]+s
        else:
            s=s+l[2]
if n%2==0:
    print(s)
else:
    print(s[::-1])


### FIXED CODE ###

from collections import deque
s=input()
q=int(input())
n=0
que=deque(s)
for i in range(q):
    l=input()
    if l[0]=='1':
        n+=1
    else:
        if (l[2]=='1' and n%2==0) or (l[2]=='2' and n%2==1):
            que.appendleft(l[4])
        else:
            que.append(l[4])

ans=''.join(que)
if n%2==0:
    print(ans)
else:
    print(ans[::-1])
### BUGGY CODE ###

import fractions


def args():
    N, MA, MB = list(map(int, input().split()))

    A, B, C = [], [], []
    for i in range(N):
        a, b, c = list(map(int, input().split()))
        A.append(a)
        B.append(b)
        C.append(c)

    # print(N, MA, MB)
    # print(A)
    # print(B)
    # print(C)

    return N, MA, MB, A, B, C


def solve(N, MA, MB, A, B, C):
    def recur(i, a, b, cost):
        if not i < N:
            if 0 < a and 0 < b:
                g = fractions.gcd(a, b)
                if (MA, MB) == (a / g, b / g):
                    return cost
            return float("inf")

        return min(recur(i + 1, a, b, cost), recur(i + 1, a + A[i], b + B[i], cost + C[i]))

    ans = recur(0, 0, 0, 0)

    return ans


if __name__ == '__main__':
    res = solve(*args())

    print(-1) if res == float("inf") else print(res)


### FIXED CODE ###

import fractions


def args():
    N, MA, MB = list(map(int, input().split()))

    A, B, C = [], [], []
    for i in range(N):
        a, b, c = list(map(int, input().split()))
        A.append(a)
        B.append(b)
        C.append(c)

    # print(N, MA, MB)
    # print(A)
    # print(B)
    # print(C)

    return N, MA, MB, A, B, C

def solve(N, MA, MB, A, B, C):
    def recur(i, a, b):
        if not MEMO[i][a][b] is None:
            return MEMO[i][a][b]

        if not i < N:
            if 0 < a and 0 < b:
                g = fractions.gcd(a, b)
                if (MA, MB) == (a / g, b / g):
                    return 0
            return float("inf")

        res = min(recur(i + 1, a, b) + 0, recur(i + 1, a + A[i], b + B[i]) + C[i])
        MEMO[i][a][b] = res
        return res

    x, y, z = N + 1, 10 * N + 1, 10 * N + 1
    MEMO = [[[None] * z for _ in range(y)] for _ in range(x)]

    ans = recur(0, 0, 0)

    return ans


if __name__ == '__main__':
    res = solve(*args())

    print(-1) if res == float("inf") else print(res)
### BUGGY CODE ###

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

L=0
R=0
DDT = 0
ans = 0
for K in range(min(d),max(d)+1):
    for i in range(N):
        if d[i] == K:
            DDT += 1
        elif d[i] < K:
            L += 1
        else:
            R += 1
    if L == R:
        ans += 1
    else:
        while DDT > 0:
            if L < R:
                L += 1
                DDT -= 1
            elif L > R:
                R += 1
                DDT -= 1
            else:
                L += 1
                DDT -= 1
        if L == R:
            ans += 1
    L = 0
    R = 0
    DDT = 0
print(ans-1)

### FIXED CODE ###

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

d.sort()

ans = d[N//2] - d[(N//2)-1]
print(ans)
### BUGGY CODE ###

N = int(input())
D = []
for i in range(N):
    D.append([int(a) for a in input().split()])
ans = 0
for i in range(N):
    for j in range(i+1,N):
        tmp = abs(D[i][0] - D[j][0]) + abs(D[i][1] - D[j][1])
        if ans < tmp:
            ans = tmp
print(ans)

### FIXED CODE ###

N = int(input())
A = [[int(a) for a in input().split()] for _ in range(N)]
for i in range(N):
    z = A[i][0] + A[i][1]
    w = A[i][0] - A[i][1]
    if i==0:
        M_z = m_z = z
        M_w = m_w = w
    if z > M_z: M_z = z
    if z < m_z: m_z = z
    if w > M_w: M_w = w
    if w < m_w: m_w = w
print(max(M_z-m_z,M_w-m_w))
### BUGGY CODE ###

from bisect import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

for i in range(N-1,1,-1):
    for j in range(i-1,0,-1):
        temp = L[i] - L[j]
        l = bisect(L,temp,lo=0,hi=j)
        cnt += j - l
print(cnt)


### FIXED CODE ###

def main():
    from bisect import bisect
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    cnt = 0

    for i in range(N-1,1,-1):
        for j in range(i-1,0,-1):
            temp = L[i] - L[j]
            l = bisect(L,temp,lo=0,hi=j)
            cnt += j - l
    print(cnt)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

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

row = []
col = []
data_e = []
data_s = []
for _ in range(m):
    u,v,a,b = map(int, input().split())
    row.append(u)
    # row.append(v)
    col.append(v)
    # col.append(u)
    data_e.append(a)
    # data_e.append(a)
    data_s.append(b)
    # data_s.append(b)

graph_e = csr_matrix((data_e, (row,col)), shape=(n+1, n+1))
graph_s = csr_matrix((data_s, (row,col)), shape=(n+1, n+1))

d_e = dijkstra(csgraph=graph_e, directed=False, indices=s)
d_s = dijkstra(csgraph=graph_s, directed=False, indices=t)

ans = [0] * (n+1)
min_cost = 10**15
for i in range(n,0,-1):
    min_cost = min(min_cost, d_e[i]+d_s[i])
    ans[i] = min_cost

for i in range(1,n+1):
    print(int(10**15 - ans[i]))

### FIXED CODE ###

import sys
input = sys.stdin.readline

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


links_e = [[] for _ in range(n+1)]
links_s = [[] for _ in range(n+1)]
for _ in range(m):
    u,v,a,b = map(int, input().split())
    links_e[u].append((a,v))
    links_e[v].append((a,u))
    links_s[u].append((b,v))
    links_s[v].append((b,u))

# dijkstra
import heapq
def dijkstra(links, start, n):
    inf = 10**10
    d = [inf] * (n+1)
    d[start] = 0
    hq = []
    used = set()
    used.add(start)
    for i in links[start]:
        heapq.heappush(hq, i)
    while(hq):
        cost,i = heapq.heappop(hq)
        if( i in used):
            continue
        d[i] = cost
        used.add(i)
        for tmp in links[i]:
            cost_next, j = tmp
            if(not j in used):
                heapq.heappush(hq, (cost+cost_next, j))
    return d

d_e = dijkstra(links_e, s, n)
d_s = dijkstra(links_s, t, n)

ans = [0] * (n+1)
min_cost = 10**15
for i in range(n,0,-1):
    min_cost = min(min_cost, d_e[i]+d_s[i])
    ans[i] = min_cost

for i in range(1,n+1):
    print(10**15 - ans[i])
### BUGGY CODE ###

def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[1]*len(A)
    for i in  range(len(A)-1):
        if ans[i]==0:
            continue
        for j in range(i+1,len(A)):
            if A[j]%A[i]==0:
                ans[j]=0
    an=0
    for i in range(len(A)-1):
        if A[i]!=A[i+1]:
            an+=ans[i]
    an+=ans[-1]
    print(an)
main1()


### FIXED CODE ###

def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[0]*(10**6+1)
    if N ==1 :
        print(1)
        return 
    for i in  range(len(A)):
        ans[A[i]]+=1
        if ans[A[i]]==1:
            for j in range(A[i]*2,10**6+1,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()
### BUGGY CODE ###

from math import sqrt
from itertools import accumulate

prime = [2]
more_prime = [0] * 100000
for i in range(3, 100000):
	j = 2
	while j <= sqrt(i):
		if i % j == 0:
			break
		j += 1
	else:
		prime.append(i)
		if (i + 1) // 2 in prime:
			more_prime[i-1] = 1

ans = list(accumulate(more_prime))

q = int(input())
for _ in range(q):
	l, r = map(int, input().split())
	if l == 1:
		l = 2
	if r == 1:
		r = 2
	print(ans[r-1] - ans[l-2])

### FIXED CODE ###

from math import sqrt
from itertools import accumulate

prime = [2]
more_prime = [0] * 100000
for i in range(3, 100000):
	j = 2
	while j <= sqrt(i):
		if i % j == 0:
			break
		j += 1
	else:
		prime.append(i)
		if (i + 1) // 2 in prime:
			more_prime[i-1] = 1

ans = list(accumulate(more_prime))

q = int(input())
for _ in range(q):
	l, r = map(int, input().split())
	if l == 1:
		l = 2
	if r == 1:
		r = 2
	print(ans[r-1] - ans[l-2])
### BUGGY CODE ###

A, B = map(int,input().split())
A_non_zero = 0
B_non_zero = 0
if A%2==1:
    A_non_zero = A
    A +=1
if B%2!=1:
    B_non_zero =B
    B -=1

count = 0
for i in range (A,B+1):
    if i%2==1:
        count +=1
        
result =bin(A_non_zero^B_non_zero^count%2)
print(int(result,2))

### FIXED CODE ###

A, B = map(int,input().split())
A_non_zero = 0
B_non_zero = 0
if A%2==1:
    A_non_zero = A
    A +=1
if B%2!=1:
    B_non_zero =B
else:
    B +=1
count = (B-A)//2
result =bin(A_non_zero^B_non_zero^count%2)
print(int(result,2))
### BUGGY CODE ###

n,k=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort()
l=[]
for i in range(len(ab)):
    for j in range(ab[i][1]):
        l.append(ab[i][0])
    if len(l)>k:break
print(l[k-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,k=map(int,input().split())
l=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    l[a-1]+=b
m=0
for i in range(10**5):
    if m+l[i]>=k:print(i+1);break
    else: m+=l[i]
### BUGGY CODE ###

H,W=map(int,input().split())
a = [[] for _ in range(H)]
for i in range(H):
    a[i] = list(map(int, input().split()))
b = [[] for _ in range(H)]
for i in range(H):
    b[i] = list(map(int, input().split()))
#print(a)
#print(b)
for i in range(H):
    for j in range(W):
        a[i][j] =abs(a[i][j]-b[i][j])
#print(a)
dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0].add(a[0][0])
dp[0][0].add(-a[0][0])
for i in range(H):
    for j in range(W):
        tmp = set()
        if i!=0:
            for k in dp[i-1][j]:
                tmp.add(abs(k+a[i][j]))
                tmp.add(abs(k-a[i][j]))
        if j!=0:
            for k in dp[i][j-1]:
                tmp.add(abs(k+a[i][j]))
                tmp.add(abs(k-a[i][j]))
        if i>0 or j>0:
            dp[i][j] = tmp
        #print(tmp)
#print(dp[H-1][W-1])
ls = list(dp[H-1][W-1])
#res = np.abs(np.asarray(ls)).argmin()
print(min(ls))


### FIXED CODE ###

import sys
input = sys.stdin.readline
H,W=map(int,input().split())
a = [[] for _ in range(H)]
for i in range(H):
    a[i] = list(map(int, input().split()))
b = [[] for _ in range(H)]
for i in range(H):
    b[i] = list(map(int, input().split()))

for i in range(H):
    for j in range(W):
        a[i][j] =abs(a[i][j]-b[i][j])

dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0].add(a[0][0])
for i in range(1,H):
    t = a[i][0]
    tmp = set()
    for k in dp[i-1][0]:
        tmp.add(k+t)
        tmp.add(abs(k-t))
    dp[i][0] = tmp
for j in range(1,W):
    t = a[0][j]
    tmp = set()
    for k in dp[0][j-1]:
        tmp.add(k+t)
        tmp.add(abs(k-t))
    dp[0][j] = tmp
for i in range(1,H):
    for j in range(1,W):
        t = a[i][j]
        tmp = set()
        for k in (dp[i-1][j] | dp[i][j-1]):
            tmp.add(k+t)
            tmp.add(abs(k-t))
        dp[i][j] = tmp
        dp[i-1][j-1] = set()

ls = list(dp[H-1][W-1])
print(min(ls))
### BUGGY CODE ###

import math
import sys
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    aList = list(map(int, readline().rstrip().split()))
    ans = 1
    for a in aList:
        if aList.count(0) > 0:
            ans = 0
            break
        if ans * a > 10 ** 18:
            ans = -1
            break
        ans *= a
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
import sys
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    aList = list(map(int, readline().rstrip().split()))
    ans = 1

    if 0 in aList:
        print(0)
        return

    for a in aList:
        ans *= a
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)


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

from functools import reduce


n = int(input())
a = list(map(int, input().split()))
ans = reduce(lambda x, y: x * y, a)
print(-1 if ans > 10**18 else ans)


### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)


main()
### BUGGY CODE ###

n, k, q = list(map(int,input().split(' ')))
import numpy as np
point = [k]*n
point = np.array(point)
#print(point)
last_point = []
for i in range(q):
  point-=1
#  print(point)
  point[int(input())-1]+=1
#  print(point)
  
for i in point:
  if i>0:
    print('Yes')
  else:
    print('No')


### FIXED CODE ###

n, k, q = list(map(int,input().split(' ')))
import numpy as np
point =np.full(n,k-q)
for i in range(q):
  win = int(input())
  point[win-1]+=1
  
  
#print(np.where(point>0,'Yes','No'))
for i in point:
  if i>0:
    print('Yes')
  else:
    print('No')