peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
N = int(input())
mod = pow(10, 9)+7
if N < 3:
    print(0)
    sys.exit()
ans = 1
for j in range(2, N//3+1):
    r = j-1
    n = N-j*3+r
    bunshi = 1
    bunbo = 1
    for i in range(r):
        bunshi = (bunshi*(n-i)) % mod
        bunbo = (bunbo*(i+1)) % mod
    ans = (ans+(bunshi*pow(bunbo, -1, mod))) % mod
print(ans)
# Judge status: Accepted


ninzu, syurui = map(int, input().split())

shoji = [ 0 for _ in range(ninzu) ]

for _ in range(syurui):
    num = int(input())
    
    if num == 1:
        man = int(input())
        shoji[man-1] += 1
    else:
        mans = map(int, input().split())
        for man in mans:
            shoji[man-1] += 1

ans = 0
for sman in shoji:
    if sman == 0:
        ans += 1

print(ans)
# Judge status: Accepted
N, x = map(int,input().split())
A = list(map(int, input().split()))

ans = 0
for i in range(0, N-1):
    if A[i] + A[i+1] > x:
        t = A[i+1] + A[i] - x

        if A[i+1] < t:
            A[i+1] = 0
        else:
            A[i+1] -= t
        ans += t

print(ans)
# Judge status: Wrong Answer
x,y=map(int,input().split())
print((x+y)//2)
# Judge status: Accepted
N = int(input())
C = {i:0 for i in range(1,N+1)}
for x in range(1,142):
    for y in range(1,142):
        for z in range(1,142):
            a = (x+y)**2+(y+z)**2+(z+x)**2
            if a%2==0 and a//2<=N:
                C[a//2] += 1
for i in range(1,N+1):
    print(C[i])
# Judge status: Accepted
s=int(input())
C=set()
C.add(s)
Cl=[s]
m=0

def f(x):
    if x%2==0:
        return int(x/2)
    else:
        return 3*x+1
while(1):
    m+=1
    x=f(Cl[m-1])
    if x in C:
        break
    Cl+=[x]
    C.add(x)
print(m+1)
# Judge status: Accepted
N,K = map(int, input().split())

count = 0
while N>0:
    N = N//K
    count = count + 1
print(count)
# Judge status: Wrong Answer
s = input()
t = input()
slen = len(s)
tlen = len(t)
ans = 10000
temp = 0

for start in range(0,slen-tlen):
    for i in range(0,tlen):
        if t[i] != s[start+i]:
            temp += 1
    ans = min(ans,temp)
    temp = 0

print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
cnt = [[] for _ in range(n + 1)]
for i in range(m):
    p, y = map(int, input().split())
    cnt[p].append((y, i))
buf = [None] * m
for p, l in enumerate(cnt):
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)
print('\n'.join(buf))
# Judge status: Wrong Answer
k,s=open(0)
k=int(k)
print(s[:k]+'...'*(len(s)>k))
# Judge status: Wrong Answer
# C - 白昼夢
S = input()
S2 = S
W_L = ["dream","dreamer","erase","eraser"]
while True:
    
    for w in W_L:
        if S2.endswith(w):
            S2 = S2[:-(len(w))]
            
    if len(S2)<=7 or not S2.endswith(w):
        break
    
if S2 ==''or S2 in W_L:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
K,A,B = map(int,input().split())

if K < A+1 or B <= A+2:
  print(K+1)
  exit(0)
  
K -= A - 1
ans = A
p,q = divmod(K,2)
ans += (B-A) * p + q
print(ans)
# Judge status: Wrong Answer

x="AtCoder"+input().capitalize()+"Contest"
print(x)

print("A"+x[8]+"C")
# Judge status: Wrong Answer
n = input()
x = input().split()
for i in range(0 , int(n)):
	x[i] = int(x[i])
min = min(x)

for i in range(min, 1 , -1):
	tmp = 0
	for ii in x:
		if int(ii) % i == 0:
			tmp += 1
	if tmp >= int(n) - 1:
		print(i)
		break
# Judge status: Wrong Answer
import math
A, B, C, K = map(int, input().split())

end = int(math.log2(10**18))

for _ in range(end+1):
    A, B, C = B+C, A+C, A+B
    if abs(A-B) > 10**18:
        print("Unfair")
        exit()

print(A-B)
# Judge status: Accepted
S = input()
K = int(input())

ans = '1'
k = 0
for s in S:
    if s == '1':
        k += 1
        if k >= K:
            ans = '1'
            break
    else:
        ans = s
        break

print(ans)
# Judge status: Accepted
import sys
row = sys.stdin.readline

def read_ints(row):
    return list(map(int, row().split()))

A,B = read_ints(row)

if A > 9 or B > 9:
  print(-1)
else:
  print(A*B)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
 
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(1, A + 1):
  for j in range(1, B + 1):
    for k in range(1, C + 1):
      if 500 * i + 100 * j + 50 * k == X:
        count += 1
print(count)
# Judge status: Wrong Answer
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if(i*j==n):
      print("YES")
      exit()
print("NO")
# Judge status: Wrong Answer
a=int(input())
b=list(map(int,input().split()))
c=0
for i in range(a):
  for k in range(a):
    for h in range(a):
      if b[i]+b[k]>=b[h]:
        c=c+1
print(c)
# Judge status: Accepted
def favorite_sound(a, b, c):

    return c if b//a > c else b//a
def main():
    a, b, c = map(int, input().split())
    print(favorite_sound(a, b, c))

if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b, n = map(int, input().split())
ref = min(b - 1, n)

ans = a*ref//b - a*(ref//b)

print(ans)
# Judge status: Accepted
s = input()

s_a = int(s[:2])
s_b = int(s[2:])

if s_a >= 1 and s_a <=12 and s_b >= 1 and s_b <=12:
  ans = "AMBIGUOUS"
elif (s_a > 12 or s_a == 0) and s_b >= 1 and s_b <=12:
  ans = "YYMM"
elif (s_b > 12 or s_b == 0) and s_a >= 1 and s_a <=12:
  ans = "MMYY"
else:
  ans = "NA"

print(ans)
# Judge status: Accepted
import math

r = int(input())
ans = math.pi * 2 * r

print(ans)
# Judge status: Wrong Answer
N,X=map(int,input().strip().split())
x=list(map(int,input().strip().split()))

x.sort()

d=[]
for n in range(1,N):
    d.append(x[n]-x[n-1])

def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    tmp=x%y
    if tmp==0:
        return y
    else:
        return gcd(y,tmp)

if len(d)==0:
    print(abs(x[0]-X))
else:
    D=d[0]
    for i in range(1,len(d)):
        D=gcd(D,d[i])
    print(D)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
n = 0
for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3 != 0 and A[i]%5 != 0:
            n = 1

if n == 0:
    print('APPROVED')
elif n == 1:
    print('DENIED')
# Judge status: Accepted
def find_max_rectangle(pair):
  """
  Args:
    pair (list): reversely sorted 
  Returns:
    area (int)
  """
  if len(pair) >= 2:
    M = pair[0]
    second_max = pair[1]
    return M * second_max
  else:
    return 0



n = int(input())
L = list(map(int, input().split()))
L.sort()
pair = []
prev = None
while L:
  popped = L.pop()
  if prev == popped:
    pair.append(prev)
    prev = None
  else:
    prev = popped

print(find_max_rectangle(pair))
# Judge status: Accepted
s = input()
print( 2*min( s.count('1'), s.count('0')))
# Judge status: Accepted
a,b,k=map(int,input().split())
lst=[]
for i in range(a,min(a+k, b)):
  lst.append(i)
  print(i)
for j in range(max(a, b-k+1),b+1):
  if j not in lst:
    print(j)
# Judge status: Wrong Answer
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
total=1
i=a[0]-1
while True:
    if a[i]==2:
        print(total+1)
        break
    elif total>n:
        print("-1")
        break
    else:
        i=a[i]-1
        total+=1
# Judge status: Accepted
a = int(input())
b = int(input())
h = int(input())

print( int((a+b)*h/2) )
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))

result = [0]
for i in range(N - 1):
    aij = a[i] ^ a[i + 1]
    result.append(result[i] ^ aij)

print(" ".join(map(str, result)))
# Judge status: Accepted
x  = int(input())
happy = 0
if x // 500 > 0:
  happy += 1000 * (x // 500)
x %= 500
if x // 5 > 0:
  happy += 5 * (x // 5)
print(happy)
# Judge status: Accepted
import math
def C(x):
  return math.ceil(x/10)*10
def I():
  return int(input())
def S(x):
  s=str(x)
  if s[-1]!='0':
    return 10-int(s[-1])
  else:
    return 0
a,b,c,d,e=I(),I(),I(),I(),I()
sum=C(a)+C(b)+C(c)+C(d)+C(e)
x=max(S(a),max(S(b),max(S(c),max(S(d),S(e)))))
print(sum-x)
# Judge status: Accepted
a, b, c = list(map(int, input().split()))
k = int(input())
 
ans = False
 
for i in range(k):
    if c <= b:
        c *= 2
    elif b <= a:
        b *= 2
    else:
        ans = True
        break
if c > b and b > a:
    ans = True

if ans:
  	print("Yes")
else:
  	print("No")
# Judge status: Accepted
n = int(input())
csf = [list(map(int,input().split())) for i in range(n-1)]
t = [[0] * n for i in range(n)]
for i in range(n-1):
    cc, cs, cf = csf[i][0], csf[i][1], csf[i][2]
    t[i][i] = cs
    for j in range(1+i):
        cs = csf[i][1]
        while t[j][i] > cs:
            cs += cf
        t[j][i+1] = cs + cc 
for i in range(n):
    print(t[i][n-1])
# Judge status: Accepted
a,b=[i for i in input().split()]
n,m=[int(i) for i in input().split()]
s=input()
if s == a:
  n-=1
else:
  m-=1
print(n,m)
# Judge status: Wrong Answer
X = input().rstrip() + "#"
s0 = X[0]
P = []
cnt = 1
for s in X[1:]:
    if s==s0:
        cnt += 1
    else:
        P.append(cnt)
        cnt = 1
    s0 = s
res = 0
if X[0] == "T":
    res = P[0]*2
if X[-2] == "S":
    res = max(P[-1]*2, res)
print(res)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
abss = [abs(A[i]) for i in range(N)]
minus = [A[i] for i in range(N) if A[i] < 0]
if len(minus) % 2 == 0:
    ans = sum([abs(A[i]) for i in range(N)])
    print(ans)
else:
    abss.sort()
    ans = -abss[0] + sum(abss[1:])
    print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
if a + b + c >= 22:
    print("bust")
elif a + b + c <= 21:
    print("win")
# Judge status: Accepted
n, m = map(int, input().split())
an = []

for i in range(n):
  l = [int(num) for num in input().split()]
  an.append(l[1:])

check = {}
for i in an:
  for j in i:
    if j not in check:
      check[j] = 1
    else :
      check[j] += 1

answer = 0
for v in check.values() :
  if v == n:
    answer +=1
      
print(answer)
# Judge status: Accepted
N = int(input())
s_10 = []
s_not_10 = []

for _ in range(N):
    s = int(input())
    if s % 10 == 0:
        s_10.append(s)
    else:
        s_not_10.append(s)

if len(s_not_10) == 0:
    print(0)
    exit(0)

s_not_10_sum = sum(s_not_10)
if s_not_10_sum % 10 != 0:
    print(s_not_10_sum+sum(s_10))
    exit(0)

s_not_10.sort()
print(s_not_10_sum+sum(s_10)-s_not_10[0])
# Judge status: Accepted
a = int(input())
b = int(input())
lst = [1, 2, 3]
for i in lst:
    if a != i and b != i:
        print(i)
# Judge status: Wrong Answer
A,B = map(int,input().split())
if (A+B)%3==0 or A>=3 or B >=3:
  print("Possible")
else:
  print("Impossible")
# Judge status: Wrong Answer
n, m = map(int, input().split())

drink = {}
for i in range(n):
  a, b = map(int, input().split())
  drink[a] = b

ans = 0
for ai, bi in sorted(drink.items(), key=lambda x:x[0]):
  ans += ai * min(drink[ai], m)
  m -= drink[ai]
  if m <= 0:
    break
print(ans)
# Judge status: Accepted
x = input()
N = len(x)
x1 = "01" * (N//2)
x2 = "10" * (N//2)
if N%2 == 1:
  x1 = x1 + "0"
  x2 = x2 + "1"
count1 = 0
count2 = 0
for x, y, z in zip(x, x1, x2):
  if x != y:
	  count1 += 1
  if x != z:
	  count2 += 1
count = min(count1, count2)
print(count)
# Judge status: Accepted
N = int(input())
print((N//2)*((N-1)//2+1))
# Judge status: Wrong Answer
D,N = map(int, input().split())
if N == 100:
    n = 2
else:
    n = 0
print(N*(100**(D-n)))
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

for i in range(n):
    i_temperature = t - h[i]*0.006
    dif_a = abs(a - i_temperature)
    if i == 0:
        champ = dif_a
    if champ >= dif_a:
        champ = dif_a
        ans = i+1

print(ans)
# Judge status: Accepted
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
sum = 0
for i in range(n):
    l = bisect.bisect_left(a,b[i])
    r = bisect.bisect_right(c,b[i])
    sum += l*(n-r)
    
print(sum)
# Judge status: Wrong Answer
N = int(input())
now = [0,0]
tnow = 0
ans = 'Yes'
for i in range(N):
    t,x,y = map(int,input().split())
    dis = abs(x-now[0]) + abs(y-now[1])
    if t-tnow < dis:
        ans = 'No'
        break
    tnow = t
    now = [x,y]
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
aa = 10 ** 9
for i in range(min(a), max(a) + 1):
    ans = 0
    for j in a:
        ans += (j - i) ** 2
    aa = min(aa, ans)
print(aa)
# Judge status: Accepted
# https://atcoder.jp/contests/agc002/tasks/agc002_a
a, b = map(int, input().split())

if a > 0 and b > 0:
    print('Positive')
elif a <= 0 and 0 <= b:
    print('Zero')
else:
    d = b - a
    if d % 2 == 0:
        print('Negative')
    else:
        print('Positive')
# Judge status: Accepted
a = int(input())
l=list(input())
b = l.count("R")
s = 0
for i in range(b):
  if l[i]=="W":
    s = s+1
print(s)
# Judge status: Accepted
n,m = sorted(list(map(int, input().split())))
if n==1:
    if m==1:
        print(1)
    else:
        print(m-2)
elif n==2:
    print(0)

else:
    print((n-2)*(m-2))
# Judge status: Wrong Answer
from math import gcd

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

D = gcd(A, B)
d = D
ans = 1
i = 2
while i <= pow(D, 1/2):
  if d%i == 0:
    ans += 1
    while d%i == 0:
      d //= i
  i += 1
print(ans)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]

ct = {}
ans = ''

for i in s:
    C = Counter(i)
    for j in C.items():
        ct[j[0]] = min(ct.get(j[0], 27), j[1])
    for j in ct.items():
        ct[j[0]] = min(j[1], C.get(j[0], 0))

ct = sorted(ct.items())
for i in ct:
    ans += i[0] * i[1]

print(ans)
# Judge status: Wrong Answer

#n,m=map(int,input().split())
a=int(input())
print(1000-(a%1000))
# Judge status: Wrong Answer
s = input()
t = input()
if s[0:-1] == t[0:-2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, M = map(int, input().split())
cnt = [0] * M

for i in range(N):
    line = list(map(int, input().split()))[1:]
    for j in line:
        cnt[j-1] += 1

ans = sum([1 if i == N else 0 for i in cnt])
print(ans)
# Judge status: Wrong Answer
n=int(input())
ar=3
sv=[0]*(10**6+2)
for i in range(2,len(sv)):
	if not sv[i]:
		sv[i]=i
		for j in range(2*i,len(sv),i):
			sv[j]=i
def di(x):
  an=1
  if sv[x]==x:
    return 2
  while x>1:
    ct=0;cr=sv[x]
    while x%cr==0:
      ct+=1;x//=cr
    an*=(ct+1)
  return an
for i in range(4,n+1):
  ar=ar+di(i-1)
print(ar)
# Judge status: Accepted
N=int(input())
S=input()
print(*[chr((ord(c)-65+N)%26+65) for c in S],sep='')
# Judge status: Wrong Answer
s = input()
t = input()
ans = len(t)

for i in range(len(s) - len(t)):
    dif = 0
    for j in range(len(t)):
        if t[j] != s[i + j]:
            dif = dif + 1

    ans = min(ans, dif)
print(ans)
# Judge status: Accepted
n, a, b = map(int, input().split())

s = a + b
n_s = n // s
l = n - s * n_s

if l <= a:
	ans = a * n_s + l
else:
    ans = a * n_s + a
    
print(ans)
# Judge status: Wrong Answer
from math import log
n = int(input())


def make_list(n, x):
    return [x ** i for i in range(1, int(log(n, x))+1)]


sixes = make_list(n, 6)
nines = make_list(n, 9)
nums = [1] + sixes + nines

dp = [float('inf')] * (n+1)
for num in nums:
    for i in range(1, n+1):
        if i == num:
            dp[i] = 1
        else:
            dp[i] = min(dp[i], dp[i-num]+1)
print(dp[n])
# Judge status: Accepted
import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W + 1, dtype=np.int)
for _ in range(N):
  w, v = map(int, input().split())
  dp[w:] = np.maximum(dp[w:], dp[:-w] + v)
print(dp[W])
# Judge status: Wrong Answer
n,k=map(int,input().split())
n=0
while n>=k**n:
    n+=1
print(n)
# Judge status: Accepted
N = int(input())
ans = 0

if N % 2 == 1:
    print(0)
    exit()

N = N // 2

while (N >= 5):
    N = N // 5
    ans += N

print(ans)
# Judge status: Accepted

a,b=map(int,input().split())
x=a+b
if x<24:print(x)
else:print(x-24)
# Judge status: Wrong Answer
# coding: utf-8
import sys
from math import log

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
    n = ni()
    m = int(log(n,26))
    ans = ''
    for i in range(m+1):
        ans += ascii_lowercase[n%26-1]
        n //= 26
    print(ans[::-1])
    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
n,m = map(int,input().split())
x=list(map(int,input().split()))
"""
2 5
10 12 1 2 14
1 2 10 12 14
->5
3 7
-10 -3 0 9 -100 2 17
-100 -10 -3 0 2 9 17
->19
100 1
-100000
->0
"""
if n >= m:
  print(0)
else:
  x.sort()
  xd=[]
  xp=x[0]
  for xi in x[1:]:
    xd.append(xi-xp)
    xp=xi
  xd.sort(reverse=True)
  print(sum(xd[n-1:]))
# Judge status: Accepted
#!/usr/bin/env python3

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

ct = [list(map(int, input().split())) for _ in range(n)]

ct = sorted(ct, key=lambda x: x[0])

# print(n, t)
# print(ct)
for i in ct:
    if i[1] <= t:
        print(i[0])
        exit()

print("TLE")
# Judge status: Wrong Answer
A,B = map(int,input().split())
d = []
for i in range(1,10):
    for j in range(10):
        for k in range(10):
            d.append(10001*i+1010*j+100*k)
d.sort()
import bisect
print(bisect.bisect_right(d,B)-bisect.bisect_right(d,A))
# Judge status: Wrong Answer
a,b,x = [int(i) for i in input().split()]
d = b//x - a//x
a = a/x
if a.is_integer():
    d+=1
print(d)
# Judge status: Accepted
# A - キャンディーとN人の子供イージー
def main():
    n = int(input())
    cnt = 0

    for i in range(1, n+1):
        cnt += i
    else:
        print(cnt)
 
    
if __name__ ==  "__main__":
    main()
# Judge status: Accepted
s = input()
check = True
count = 0
for i in s:
    if check:
        if i != "0":
            count += 1
    else:
        if i != "1":
            count += 1
    check = not check
check = False
count2 = 0
for i in s:
    if check:
        if i != "0":
            count2 += 1
    else:
        if i != "1":
            count2 += 1
    check = not check
print(min(count, count2))
# Judge status: Accepted
import bisect,copy,heapq,itertools,math,string
from collections import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = deque()

for i in range(n):
    if(i%2==0):
        b.append(i)
    else:
        b.appendleft(i)

if(n%2==1):
    b.reverse()

c = [a[b[i]] for i in range(n)]
print(*c)
# Judge status: Wrong Answer
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=False)
count = 0
for i in a:
    if x>=i:
        count += 1
        x -= i
    else:
        break
print(count)
# Judge status: Accepted
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    t=list(map(int,input().split()))
    s.append(t)
for i in range(d):
    print(i%26+1)
# Judge status: Wrong Answer
s,c = map(int,input().split())

print((2*s+c)//4)
# Judge status: Accepted
n, a, b = list(map(int, input().split()))
s = list(input())

sum = a + b
passingD = 0  # 国内
passingF = 0  # 海外
flag = 'No'

for i, student in enumerate(s, 1):
    if student == 'a' and (passingD + passingF) < sum:
        passingD = passingD + 1
        flag = 'Yes'
    elif student == 'b' and (passingD + passingF) < sum and passingF < b:
        passingF = passingF + 1
        flag = 'Yes'
    else:
        flag = 'No'

    print(flag)
# Judge status: Accepted
s = input()
ansL = [s[0]]
ans = ""
for i in s[1:]:
    ans += i
    if ansL[-1] != ans:
        ansL.append(ans)
        ans = ""
print(len(ansL))
# Judge status: Accepted
N = int(input())

dic = {}
B = []

for i in range(N):
    a, b = map(int,input().split())
    B.append(b)
    if '{}'.format(b) in dic:
        dic['{}'.format(b)] += a
    else:
        dic['{}'.format(b)] = a

Bs = sorted(list(set(B)))

time = 0

for i, num in enumerate(Bs):
    time += dic['{}'.format(num)]
    if num < time:
        print('No')
        break

    if i == len(Bs)-1:
        print('Yes')
# Judge status: Accepted

import itertools
S = input()
RevS = reversed(S)
L = [0]#左の<
R = [0]#右の>
cur = 0
for s in S:
    if s == "<":
        cur += 1
    else:
        cur = 0
    L.append(cur)
cur = 0
for r in RevS:
    if r == ">":
        cur += 1
    else:
        cur = 0
    R.append(cur)
R.reverse()
ans = 0
for n in range(len(S)+1):
    ans += max(L[n],R[n])
print(ans)
# Judge status: Accepted
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

yen = 1000
for i in range(1, N):
    if A[i-1] < A[i]:
        yen += (A[i] - A[i-1]) * (yen // A[i-1])

print(yen)
# Judge status: Accepted
input1 = input().split()
A = input1[0]
s = input1[1]
C = input1[2]
listA = [str(x) for x in A]
listS = [str(y) for y in s]
listC = [str(z) for z in C]
print(listA[0] + listS[0] + listC[0])
# Judge status: Accepted
a, b = [int(x) for x in input().split()]
if a <= 9 and b <= 9:
    print(a * b)
else:
    print(-1)
# Judge status: Wrong Answer
A,B,C = map (int, input ().split ())
if A>B>C or A>C>B:
  print (B+C)
elif B>A>C or B>C>A:
  print (A+C)
else:
  print (A+B)
# Judge status: Accepted
import numpy as np
N=int(input())
A=[int(input()) for i in range(5)]

t=0
x=np.argmin(A)

t+=x

t+=(N+A[x]-1)//A[x]

t+=4-x

print(t)
# Judge status: Accepted
n = int(input())
data = list(map(int, input().split()))

total = sum(data)
x = 0
ans = 2 * 10**9 + 1
last = data[-1]
for i in range(len(data)-1):
    x += data[i]
    score = abs(2*x - total)
    if score < ans:
        ans = score
print(ans)
# Judge status: Wrong Answer
S = int(input())
slen = int(S/3)
Ans = 0
for i in range(1,slen+1):
    szan = S - 3*i
    Ans += i**szan
    # print(i**szan)
print(Ans%(10**9+7))
# Judge status: Wrong Answer
N = int(input())

#nの約数列挙
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    ass.sort()
    return ass #sortされていない

D = divisor(N)
ans = 0
for d in D:
    if d == 1:
        continue
    if N >= d and N%d == 0:
        N //= d
        ans += 1
print(ans)
# Judge status: Accepted
from collections import Counter
from functools import reduce
MOD = 10 ** 9 + 7

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

c = Counter(s)

ans = reduce(lambda total, x: total * (x+1) % MOD, c.values(), 1)

print(ans-1)
# Judge status: Accepted
N,M = (int(x) for x in input().split())
cor = 0
mis = 0
numList = [0] * N
misList = [0] * N

for _ in range(M):
    num,ans = input().split()

    if ans == 'WA':
        misList[int(num)-1] += 1
    else:
        if numList[int(num)-1] == 0:
            mis += misList[int(num)-1]
            cor += 1
            numList[int(num)-1] = 1

print(cor,mis)
# Judge status: Wrong Answer
def main():
    s=input()
    t=input()
    res=0
    for i in range(len(s)):
        if(s[i]==t[i]):
            res+=1
    print(res)
if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))
A = sorted(X)
mid = (A[N//2] + A[N//2-1]) / 2

for x in X:
    if x < mid: print(A[N//2])
    else: print(A[N//2-1])
# Judge status: Wrong Answer
import collections

n, k, q = map(int, input().split())
a = [input() for i in range(q)]

p = []
max_v = 0

if k > q:
    for i in range(n):
        print("Yes")
else:
    count = collections.Counter(a)
    max_v = max(count.values())
 
    result = [key for key, val in count.items() if val == max_v]

    for i in range(n):
        if str(i + 1) in result:
            print("Yes")
        else:
            print("No")
# Judge status: Accepted
n,m = map(int,input().split())
if n >= m:
    print(m // 2)
else:
    m = m // 2
    z = (n + m) // 2
    z = z - n
    n += z
    m -= z
    print(min(n,m))
# Judge status: Accepted
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n,d=map(int,stdin.readline().split())
print(math.ceil(n/(d+d+1)))
# Judge status: Accepted
n=int(input())
a=[int(i) for i in input().split()]

sunuke=0
araiguma=sum(a)

min_sa=100000000000000

for i in range(n-1):
    sunuke+=a[i]
    araiguma-=a[i]
    min_sa=min(min_sa,abs(araiguma-sunuke))
print(min_sa)