Harryxun/stf_run huggingface dataset:
class CumulativeSum2D:
  def __init__(self,a):
    self.h=len(a)
    self.w=len(a[0])
    self.s=[(self.w+1)*[0]for _ in range(self.h+1)]
    for i in range(self.h):
      for j in range(self.w):
        self.s[i+1][j+1]=self.s[i+1][j]+self.s[i][j+1]-self.s[i][j]+a[i][j]
    for i in self.s:print(i)
  def sum(self,i1,j1,i2,j2):
    return self.s[i2+1][j2+1]-self.s[i1][j2+1]-self.s[i2+1][j1]+self.s[i1][j1]
n,k=map(int,input().split())
a=[(3*k+7)*[0]for _ in range(3*k+7)]
for _ in range(n):
  x,y,c=input().split()
  x=int(x)
  y=int(y)
  if c=="W":x+=k
  x%=2*k
  y%=2*k
  a[x][y]+=1
  a[x+k][y]-=1
  a[x][y+k]-=1
  a[x+k][y+k]+=1
  a[x+k][y+k]+=1
  a[x+k+k][y+k]-=1
  a[x+k][y+k+k]-=1
  a[x+k+k][y+k+k]+=1
b=[(3*k+8)*[0] for _ in range(3*k+8)]
ans=0
for i in range(3*k+7):
  for j in range(3*k+7):
    b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j]
    ans=max(ans,b[i+1][j+1])
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
a=[(2*k+1)*[0]for _ in range(2*k+1)]
for _ in range(n):
  x,y,c=input().split()
  x=int(x)
  y=int(y)
  if c=="B":y+=k
  x%=2*k
  y%=2*k
  a[x+1][y+1]+=1
ans=0
for i in range(1,2*k+1):
  for j in range(1,2*k+1):a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1]
for i in range(k,2*k+1):
  for j in range(k,2*k+1):
    t=a[i][j]-a[i-k][j]-a[i][j-k]+a[i-k][j-k]
    t+=a[i-k][j-k]
    t+=a[2*k][j-k]-a[i][j-k]
    t+=a[i-k][2*k]-a[i-k][j]
    t+=a[2*k][2*k]-a[i][2*k]-a[2*k][j]+a[i][j]
    ans=max(ans,t,n-t)
print(ans)
N,K = map(int,input().split())
print(int(math.log(N,K)+1))

### FIXED CODE ###

import math
N,K = map(int,input().split())
print(int(math.log(N,K)+1))
def main():
    k = int(input())
    if (k%2==0 or k%5==0):
        print("-1")
        return

    #7(10**i-1)が9Kで割り切れるような最小の整数iを求める。

    if k%7==0:
        L=9*k/7
    else:
        L=9*k
    i=1
    for n in range(1,L+1):
        i=(10*i)%L
        if i==1:
            print(n)
            return
    print("-1")

main()

### FIXED CODE ###

def main():
    k = int(input())
    if (k%2==0 or k%5==0):
        print("-1")
        return

    #7(10**i-1)が9Kで割り切れるような最小の整数iを求める。

    if k%7==0:
        L=9*k//7
    else:
        L=9*k
    i=1
    for n in range(1,L+1):
        i=(10*i)%L
        if i==1:
            print(n)
            return
    print("-1")
    return

main()
A,B,C,K=map(int,input().split())
m=0
if A-K>=0:
  print(A):
else:
  K=K-A
  if B>=K:
    print(A)
  else:
    K=K-B
    print(A-K)
  


### FIXED CODE ###

A,B,C,K=map(int,input().split())
m=0
if A-K>=0:
  print(K)
else:
  K=K-A
  if B>=K:
    print(A)
  else:
    K=K-B
    print(A-K)
N=int(input())
A=int(input())
B=int(input())
if N==1:
    print('Hello World')
else:
    print(A+B)

### FIXED CODE ###

N=int(input())
if N==2:
    A,B=map(int,[input() for i in range(2)])
    print(A+B)
else:
    print('Hello World')
def main():
    ans = 0
    n,k = map(int, input(.split()))
    l = [0]*n
    for i in range(k):
        d = int(input())
        s = list(map(int, input().split()))
        for j in s:
            l[j-1] += 1
    for i in range(n):
        if l[i] == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    ans = 0
    n,k = map(int, input().split())
    l = [0]*n
    for i in range(k):
        d = int(input())
        s = list(map(int, input().split()))
        for j in s:
            l[j-1] += 1
    for i in range(n):
        if l[i] == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
inport bisect 
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())))

for i in range(m):
  b = a[-1]
  a.remove(b)
  b = int(b/2)
  bisect.insort_left(a,b)
  
print(sum(a))

### FIXED CODE ###

import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x: x*(-1), a))  # 各要素を-1倍することで，最小最大を逆転

heapq.heapify(a)#優先度付きキューに変換

for i in range(m):
  tmp = heapq.heappop(a)
  heapq.heappush(a,(-tmp//2)*(-1))#負の剰余では切り捨て方向が異なってしまうので，いったんプラスにする．
  
print(-sum(a))
S=sum(N/2(N+1))
print(S)

### FIXED CODE ###

N=int(input())
result = 0;
for i in range(1,N+1):
    result += i
        
print(result)
n,m=map(int,input().split())
a=[b for b in int(input().split())]
def func(n,a):
    if n< sum(a):return "-1"
    else: 
        return n-sum(a)
print(func(n,a))

### FIXED CODE ###

n,m=map(int,input().split())
a=[int(b) for b in input().split()]
def func(n,a):
    if n< sum(a):return "-1"
    else: 
        return n-sum(a)
print(func(n,a))
lis = list(map(int,input().split()))
st = []
for i in lis:
  if i == "+":
    x = st.pop()
    y = st.pop()
    st.append(x+y)
  elif i == "-":
    x = st.pop()
    y = st.pop()
    st.append(y-x)
  elif i == "*":
    x = st.pop()
    y = st.pop()
    st.append(x*y)
  else:
    st.append(i)
print(st[0])  


### FIXED CODE ###

lis = input().split()
st = []
for i in lis:
  if i == "+":
    x = st.pop()
    y = st.pop()
    st.append(x+y)
  elif i == "-":
    x = st.pop()
    y = st.pop()
    st.append(y-x)
  elif i == "*":
    x = st.pop()
    y = st.pop()
    st.append(x*y)
  else:
    st.append(int(i))
print(st[0])
L,R,d = (int(_) for _ in input().split())
 
for i in range(d):
  if(i%d == 0) cnt++
  
print(cnt)

### FIXED CODE ###

L,R,d=map(int, input().split())
cnt=0
 
for i in range(L, R+1):
  if i%d == 0: cnt+=1
  
print(cnt)
l = map(int, input().split())

print(l[0] + l[1]/2)

### FIXED CODE ###

x, y = map(int, input().split())
print(x + y//2)
# -*- coding: utf-8 -*-
import fraction
 
tmp=input()
n = int(tmp.split(" ")[0])
X = int(tmp.split(" ")[1])
tmp=input()
i=int(0)
x=[]
for i in range(n):
    x.append(int(tmp.split(" ")[i]))
x.append(X)
x.sort()
y=[]

i=0
while i < n:
    y.append(x[i+1]-x[i])
    i +=1
y.sort()

z=y[0]
i=0
while i < n:
    z=fraction.gcd(z,y[i])
    i+=1

print(z)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import fractions
import numpy as np
 
N,X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
 
x=np.array(x)
 
y=x[1:]-x[:-1]
 
y.sort()
y=list(set(y))
z=y[0]
m=len(y)
i=0
while i < m:
    z=fractions.gcd(z,y[i])
    i+=1
 
print(z)
import math
a,b,c,d=map(int,input().split())
c-=a;d-=b;
g=math.gcd(c,d)
j=c//g;k=d//g
print((j+k-1)*g)

### FIXED CODE ###

def gcd(a,b):
	if b==0:return a
	return gcd(b,a%b)
a,b,c,d=map(int,input().split())
c=abs(c-a)
d=abs(d-b)
g=gcd(max(c,d),min(c,d))
j=int(c/g)
k=int(d/g)
print((j+k-1)*g)
d={}
d[a]=list(input())
d[b]=list(input())
d[c]=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(upper(now))

### FIXED CODE ###

d={}
d['a']=list(input())
d['b']=list(input())
d['c']=list(input())
now='a'
while True:
  if len(d[now])>0:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(10**5)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	n = int(rl())

	@lru_cache(None)
	def dp(i, has0, has9):
		if i == n: return 1 if (has0 and has9) else 0
		cnt = 0
		for d in range(10):
			cnt += dp(i+1, has0 or d == 0, has9 or d == 9)
			cnt %= MOD 
		return cnt 

	print(dp(0, 0, 0))

	stdout.close()

if __name__ == "__main__":
	main()

### FIXED CODE ###

from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

# setrecursionlimit(10**7)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	n = int(rl())

	dp = [[[0 for k in range(2)] for j in range(2)] for i in range(n+1)]
	dp[0][0][0] = 1

	for i in range(n):
		for j in range(2):
			for k in range(2):
				for d in range(10):
					nj = j or d == 0
					nk = k or d == 9
					dp[i+1][nj][nk] += dp[i][j][k]
					dp[i+1][nj][nk] %= MOD 

	ans = dp[n][1][1]
	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()
a = list(map(int,input().split()))
N = a[0]
X = a[1]
Y = a[2]
ans = []
for k in range(1,N+1):
  ans[k] = N-k

for i in range(1,N):
  for j in range(2,N+1):
    k = min(j-i,abs(X-i)+1+abs(j-Y))
    ans[k] = ans[k]+1

for dist in ans:
  print(dist)
      




### FIXED CODE ###

a = list(map(int,input().split()))
N = a[0]
X = a[1]
Y = a[2]
ans = list(range(N))
for k in range(1,N):
  ans[k] = 0
 
for i in range(1,N):
  for j in range(i+1,N+1):
    k = min(j-i,abs(X-i)+1+abs(j-Y))
    ans[k] = ans[k]+1
 
for t in range(1,N):
  print(ans[t])
K = int(input())
A, B = map(int, input().split())

A_bai = int(A/K)
B_bai = int(B/K)

if A_bai != B_bai:
  print("OK")
else if (A%K == 0) || (B%K == 0):
  print("OK")
else:
  print("NG")


### FIXED CODE ###

K = int(input())
A, B = map(int, input().split())

A_bai = int(A/K)
B_bai = int(B/K)

if A_bai != B_bai:
  print("OK")
elif (A%K == 0) or (B%K == 0):
  print("OK")
else:
  print("NG")
n = int(input())
power = 1
for i in range(1,n+1):
    power *= i
    power = power % (10 ** 9 + 7))

print(power % (10 ** 9 + 7))

### FIXED CODE ###

n = int(input())
power = 1
for i in range(1,n+1):
    power *= i
    power = power % (10 ** 9 + 7)

print(power % (10 ** 9 + 7))
n = int(input())
a = int(input())
m = n % 500
if a >=　m :
  print('Yes')
else:
  print('No')


### FIXED CODE ###

n=int(input())%500
a=int(input())
print('Yes' if a>=n else 'No')
N,M,C = list(map(int,input().split()))
B = list(map(int,input().split()))
A = []
for i in range(N):
    A.append(list(map(int,input().split())))
S = []
count = 0
for i in range(N):
    for j in range(M):
        S.append(A[j]*B[j])
    if sum(S) > -1 * C:
        count += 1
    S = []
print(count)

### FIXED CODE ###

N,M,C = list(map(int,input().split()))
B = list(map(int,input().split()))
A = []
for i in range(N):
    A.append(list(map(int,input().split())))
S = []
count = 0
for i in range(N):
    for j in range(M):
        S.append(A[i][j]*B[j])
    if sum(S) > -1 * C:
        count += 1
    S = []
print(count)
N, K = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
S = []
a = 1
number = 0
numbers=[-1 for _ in range(N)]
for _ in range(N + 1):
    b = A[a - 1]
    if numbers[b-1] != -1:
      c=numbers[b-1]
      break
    numbers[b-1]=number
    number += 1
    S.append(b)
    a = b
T = S[c:number]
if number==N+1:
  answer=K%N
  print(S[answer])
else:
  if K <= N:
    print(S[K - 1])
  else:
    z = K - c - 1
    y = z % (number - c)
    print(T[y])


### FIXED CODE ###

N, K = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
S = [1]
a = 1
number = 0
numbers=[-1 for _ in range(N)]
for _ in range(N + 1):
    b = A[a - 1]
    if numbers[b-1] != -1:
      c=numbers[b-1]
      break
    numbers[b-1]=number
    number += 1
    S.append(b)
    a = b
T = S[c+1:number+1]
if K <= number:
  print(S[K ])
else:
  z = K - c-1
  y = z % (number - c)
  print(T[y])
a, b = map(int, input().split())
print(`Even` if a*b % 2 = 0 else `Odd`)

### FIXED CODE ###

a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")
k,x = map(int,input().split())

min_ans = x-k+1
max_ans = x+K-1

for x in range(min_ans,max_ans+1):
  print(x, end=" ")
  

### FIXED CODE ###

k,x = map(int,input().split())

min_ans = x-k+1
max_ans = x+k-1

for x in range(min_ans,max_ans+1):
  print(x, end=" ")
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    C = list(int(input()) for _ in range(n))

    dp = [0] * (n + 1)
    dp[0] = 1
    dp2 = [-1] * (n + 1)
    for i in range(n):
        c = C[i]
        if dp2[c] >= 0 and dp2[c] < i - 1:
            dp[i + 1] = dp[i] + dp[dp2[c] + 1]
        else:
            dp[i + 1] = dp[i]
        dp2[c] = i

    print(dp[-1])


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    C = list(int(input()) for _ in range(n))
    MAX_C = max(C)

    dp = [0] * (n + 1)
    dp[0] = 1
    dp2 = [-1] * (MAX_C + 1)
    for i in range(n):
        c = C[i]
        if dp2[c] >= 0 and dp2[c] < i - 1:
            dp[i + 1] = dp[i] + dp[dp2[c] + 1]
        else:
            dp[i + 1] = dp[i]
        dp[i + 1] %= mod
        dp2[c] = i

    print(dp[-1] % mod)


if __name__ == '__main__':
    resolve()
n=int(input())
max=-1000001;min=1000001;g=0;i=0;
num=list()
while i<n:
 j=int(input().split())
 if max<j:
  max=j
 if min>j:
  min=j
 g+=j
 i+=1
print(min,max,g)


### FIXED CODE ###

n=int(input())
max=-1000001;min=1000001;g=0;i=0;
num=list(map(int,input().split()))
for x in num:
 if max<x:
  max=x
 if min>x:
  min=x
 g+=x
 i+=1
print(min,max,g)
# -*- coding: utf-8 -*-
n = str(input())
S = n.replace(1,9).replace(9,1)

### FIXED CODE ###

# -*- coding utf-8 -*-
n = str(input())
S = n.replace("1","8")
T = S.replace("9","1")
U = T.replace("8","9")
print(U)
s = input()
if s == 'RRR':
  return 3
elif s == 'RRS' or s == 'SRR':
  return 2
elif s == 'SSS':
  return 0
else:
  return 1

### FIXED CODE ###

s = input()
if s == 'RRR':
  print(3)
elif s == 'RRS' or s == 'SRR':
  print(2)
elif s == 'SSS':
  print(0)
else:
  print(1)
import math

while True:
    try:
        x = int(raw_input())
        print "{:5f} {:5f}".format((x * x * math.pi), (x * 2 * math.pi))

            
    except EOFError:
        break

### FIXED CODE ###

import math

while True:
    try:
        x = float(raw_input())
        print "{:5f} {:5f}".format((x * x * math.pi), (x * 2 * math.pi))

            
    except EOFError:
        break
n = int(input())
list_in = list(map(int, input().split()))
q = int(input())
for i in range(q+1):
    b,c = input().split()
    b = int(b)
    c = int(c)
    for j in range(n):
        if list_in[j]==b:
            list_in[j]=c
    print(sum(list_in))

### FIXED CODE ###

import collections
n = int(input())
list_in = list(map(int, input().split()))
q = int(input())

counter = collections.Counter(list_in)
sum = sum(list_in)

for i in range(q):
    bc = list(map(int, input().split()))
#    list_in = [bc[1] if list_in[l] == bc[0] else list_in[l] for l in range(n)]
    sum_diff = (bc[1] - bc[0]) * counter[bc[0]]
    counter[bc[1]] = counter[bc[1]] + counter[bc[0]]
    counter[bc[0]] = 0
    print(sum+sum_diff)
    sum = sum + sum_diff
#coding: utf-8
import numpy as np

A = input()
B = input()
C = input()
if((A==B and A!=C) or (A==C and A!=B )or (A!=B and B==C)):
    print ("Yes")
else:
    print("No")

### FIXED CODE ###

#coding: utf-8
import numpy as np

A,B,C = raw_input().split()
if((A==B and A!=C) or (A==C and A!=B )or (A!=B and B==C)):
    print ("Yes")
else:
    print("No")
N = int(input())

lis = [0]*60

for a in input().split():
    a = int(a)
    for i,j in range(60):
        lis[i] += a % 2
        a = a//2
ans = 0
for i, j in enumerate(lis):
    ans += j * (N-j) *(2**i)
    ans = ans % (10**9 + 7)

print(ans)


### FIXED CODE ###

N = int(input())
 
lis = [0]*60
 
for a in input().split():
    a = int(a)
    for i in range(60):
        lis[i] += a % 2
        a = a//2
ans = 0
for i, j in enumerate(lis):
    ans += j * (N-j) *(2**i)
    ans = ans % (10**9 + 7)
 
print(ans)
s = input()

set_s = set(s)

abc = 'abcdefghijklmnopqrstuvwxyz'

if len(abc) != 26:
	print('err')

set_abc = set(abc)

set_abc -= set_s

ans =[]

for c in set_abc:
	ans.append(c)
	
ans.sort()

print(ans[0])

### FIXED CODE ###

s = input()

set_s = set(s)

abc = 'abcdefghijklmnopqrstuvwxyz'

if len(abc) != 26:
	print('err')

set_abc = set(abc)

set_abc -= set_s

ans =[]

for c in set_abc:
	ans.append(c)
	
ans.sort()

if len(ans) == 0:
	print('None')
else:
	print(ans[0])
#dp
n,m  = map(int,input().split())
ln = [-1 for i in range(n +1)]
mod_1 = 10**9 + 7
for i in range(m):
    ln[int(input())] = 0
line = []
for i in range(n+1):
    if ln[i] ==0
        pass
    elif i == 0:
        ln[i] = 1
    elif i == 1:
        ln[i] = 1
    else:
        line.append((line[-1] + line[-2]) % mod_1)
print(line[-1])


### FIXED CODE ###

#dp
n,m  = map(int,input().split())
ln = [-1 for i in range(n +1)]
mod_1 = 10**9 + 7
for i in range(m):
    ln[int(input())] = 0
#print(ln)
for i in range(n+1):
    if ln[i] ==0:
        pass
    elif i == 0:
        ln[i] = 1
    elif i == 1:
        ln[i] = 1
    else:
        ln[i] = (ln[i-1] + ln[i-2]) % mod_1
#print(ln)
print(ln[-1])
N, M = list(map(int, input().split()))
P = []
S = []

def f(s):
  lst = s.split()
  return int(lst[0]),lst[1]



for i in range(M):
  p, s = f(input())
  P.append(p)
  S.append(s)

correct = 0
penalty = 0
q = []

for i, j in enumerate(S):
  if 'AC' in j:
    if P[i] not in q:
      q.append(P[i])
      relate.append(P[i])
      correct += 1
    else:
      continue
  if 'WA' in j:
    if P[i] not in q:
        penalty += 1
    else:
      continue

for i, j in enumerate(S):
  if 'WA' in j:
    if P[i] not in P:
      penalty -= 1

print(correct, penalty)

### FIXED CODE ###


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

isAC = [0] * (N+1)
isWA = [0] * (N+1)

ACnum = 0
WAnum = 0

for _ in range(M):
    p, s = input().split()
    p = int(p)

    if isAC[p] == 1: continue
    if s == 'AC':
        isAC[p] = 1
        ACnum += 1
        WAnum += isWA[p]
    elif s == 'WA':
        isWA[p] += 1

print("%d %d"%(ACnum, WAnum))
a = input()
b = input()

answer_list = {"1","2","3"}
answer_list -= a
answer_list -= b

print(answer_list[0])

### FIXED CODE ###

a = input()
b = input()
 
answer_list = ["1","2","3"]
answer_list.remove(a)
answer_list.remove(b)
 
print(answer_list[0])
import math
N = int(input())
x = list(map(int, input().split()))
 
s = float((x[0] + x[1])/2)
for i in range(2,N-1):
	s = (s + x[i]) / 2
 
min = math.floor(s)
 
print(min)

### FIXED CODE ###

N = int(input())
x = list(map(int, input().split()))
 
t = 0
min = 0

for i in range(0,N):
     t += x[i]/N

s = round(t)
for i in range(0,N):
    min += (x[i] - s) **2

print(min)
h, w = map(int, input().split())

ll = [list(input()) for _ in range(h)]
lh = [h for h in ll if '#' in h]
lw = zip(*[w for w in zip(*lh) if '#' in w])

for l in lw:
  print(''.join(l))

### FIXED CODE ###

n, i = map(int,input().split())
print(n-i+1)
str = input()
max = 0
count = 0
for chr in str:
	if chr == 'A' or chr == 'C' or chr == 'G' or chr == 'T':
		count += 1
   		if count > max:
        	max = count
  	else:
  		count = 0
print('{}'.format(max))

### FIXED CODE ###

str = input()
max = 0
count = 0
for chr in str:
    if chr == 'A' or chr == 'C' or chr == 'G' or chr == 'T':
        count += 1
        if count > max:
            max = count
    else:
        count = 0
print('{}'.format(max))
N=int(input())
n=[str(input()) for i in range(N)]
M=int(input())
m=[str(input()) for i in range(M)]
for i in range(N):
  print(max(0, max(n.count(n[i-1])-m.count(n[i-1]))))

### FIXED CODE ###

N=int(input())
n=[str(input()) for i in range(N)]
M=int(input())
m=[str(input()) for i in range(M)]
print(max(0, max(n.count(n[i])-m.count(n[i]) for i in range(N))))
n, m = map(int, input().split())
As = list(map(int, input().split()))

vacation = n-sum(As)
if vacation < 0:
	print('-1')
else:
	print vacation

### FIXED CODE ###

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

vacation = n-sum(As)
if vacation < 0:
	print('-1')
else:
	print(vacation)
n=input()

S=range(1,14)
H=range(1,14)
C=range(1,14)
D=range(1,14)
 
for i in range(n):
   m, k=raw_input().split()
   if m == 'S':
      S[int(k)-1] = 0
   elif m == 'H':
       H[int(k)-1] = 0
   elif m == 'C':
       C[int(k)-1] = 0
   elif m == 'D':
       D[int(k)-1] = 0

for i in range(0, 13):
   if S[i] != 0:
      print 'S '+str(S[i])

for i in range(0, 13):
   if h[i] != 0:
      print 'H '+str(H[i])

for i in range(0, 13):
   if C[i] != 0:
      print 'C '+str(C[i])

for i in range(0, 13):
   if d[i] != 0:
      print 'D '+str(D[i])

### FIXED CODE ###

n=input()
  
s=range(1,14)
h=range(1,14)
c=range(1,14)
d=range(1,14)
   
for i in range(n):
   m, k=raw_input().split()
   if m == 'S':
      s[int(k)-1] = 0
   elif m == 'H':
      h[int(k)-1] = 0
   elif m == 'C':
      c[int(k)-1] = 0
   elif m == 'D':
      d[int(k)-1] = 0
  
for i in range(0, 13):
   if s[i] != 0:
      print 'S '+str(s[i])
  
for i in range(0, 13):
   if h[i] != 0:
      print 'H '+str(h[i])
  
for i in range(0, 13):
   if c[i] != 0:
      print 'C '+str(c[i])
  
for i in range(0, 13):
   if d[i] != 0:
      print 'D '+str(d[i])
#!/usr/bin/env python3
import sys
from math import factorial



MOD = 1000000007  # type: int


def cmb(n, r, p):
    return (factorial(n) // (factorial(r) * factorial(n - r)))

def solve(N: int, K: int):
    c = N-K+1

    for i in range(K):
        # i回の操作でとるために両端を除くセパレータの数はi-1個
        b = cmb(K-1, i, MOD)
        # 両端を含めたセパレータの数はi-1+2個
        # セパレータには最低1つ配属するので，配置する赤玉の数はN-K-(i-1)個
        # この赤玉をi+1個のセパレータに配属させる
        # i+1 H N-K-(i-1)
        if c-i<0:
            print(0)
        else:
            k = cmb(c, c-(i+1), MOD)
        print(b*k%MOD)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from math import factorial
MOD = 1000000007  # type: int

def cmb(n, r, p):
    return (factorial(n) // (factorial(r) * factorial(n - r))%p)

def solve(N: int, K: int):
    c = N-K

    for i in range(K):
        # i+1回の操作でとるために両端を除くセパレータの数はi個
        # 両端を含めたセパレータの数はi+2個
        # セパレータには最低1つ配属するので，配置する赤玉の数はN-K-i個
        # この赤玉をi+2個のセパレータに配属させる
        # i+2 H c-i
        if c-i<0:
            print(0)
        else:
            b = cmb(K-1, i, MOD)
            k = cmb(c+1, c-i, MOD)
            print(b*k%MOD)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()
import copy
import functools
import math

n=int(input())
lstA=list(map(int,input().split()))
maximum=max(lstA)
gcdlst=[]

for i in range(n):
    cplstA=copy.copy(lstA)
    del cplstA[i]
    gcdlst.append(functools.reduce(math.gcd, cplstA))

print(max(gcdlst))


### FIXED CODE ###

#import sys
#input=sys.stdin.readline

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


def main():
    n = int(input())
    A = list(map(int, input().split()))
    gcdA = [0]*n
    gcdB = [0]*n
    gcdA[0] = A[0]
    gcdB[n-1] = A[n-1]
    for i in range(1, n):
        gcdA[i] = gcd(A[i], gcdA[i-1])
        gcdB[n-i-1] = gcd(A[n-i-1], gcdB[n-i])
    ans = max(gcdA[n-2], gcdB[1])
    for i in range(1, n-1):
        ans = max(ans, gcd(gcdA[i-1], gcdB[i+1]))
    print(ans)


if __name__ == "__main__":
    main()
n=int(input())
a=list(map(int,input().split()))
import math
mini=float('inf')
for i in range(n-1):
    x=math.gcd(a[i],a[i+1])
    mini=min(mini,x)
print(mini)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
import fractions as f
mini=float('inf')
for i in range(n-1):
    x=f.gcd(a[i],a[i+1])
    mini=min(mini,x)
print(mini)