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

N=int(input())
A=[]
ans=0
for i in range(N):
    a=int(input())
    A.append(a)
cl=[A[-1]]
ans=1
for i in range(N-1)[::-1]:
    a=A[i]
    flag=0
    for j in range(len(cl)):
        if cl[j]>a:
            cl[j]=a
            flag=1
            break
    if flag==0:
        cl.append(a)
        ans+=1
        cl.sort()
print(ans)

### FIXED CODE ###

import bisect
N=int(input())
A=[]
ans=0
for i in range(N):
    a=int(input())
    A.append(a)
cl=[A[-1]]
ans=1
for i in range(N-1)[::-1]:
    a=A[i]
    if a>=cl[-1]:
        cl.append(a)
        ans+=1
    else:
        b=bisect.bisect_right(cl,a)
        cl[b]=a
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from bisect import bisect_left
from sys import stdin
from heapq import heappush, heappop



readl = stdin.readline
def main():
  ## input
  N,Q = map(int, readl().rstrip().split())
  STX = [list(map(int, readl().rstrip().split())) for _ in range(N)]
  Dn = [int(readl().rstrip()) for _ in range(Q)] + [10**10]
  ans = []

  for s,t,x in sorted(STX,key=lambda x:x[2]):
    l = r = bisect_left(Dn,s-x)
    t -= x
    while Dn[r] < t:
      heappush(ans, (Dn[r],x))
      r += 1
    del Dn[l:r]

  for d in Dn[:-1]:
    heappush(ans, (d,-1))

  return ans,Q


if __name__ == "__main__":
  ans,n = main()
  for _ in range(n):
    print(heappop(ans)[1])    


### FIXED CODE ###

import sys
from bisect import bisect_left



N,Q = map(int, input().split())
lines = sys.stdin.readlines()
kkk = []
for line in lines[:N]:
  s, t, x = map(int, line.split())
  kkk.append((x, s, t))
kkk.sort()
ddd = list(map(int, lines[N:]))

ans = [-1] * Q
skip = [-1] * Q
for x, s, t in kkk:
  ss = bisect_left(ddd, s - x)
  tt = bisect_left(ddd, t - x)
  while ss < tt:
    sk = skip[ss]
    if sk == -1:
      ans[ss] = x
      skip[ss] = tt
      ss += 1
    else:
      ss = sk

print('\n'.join(map(str, ans)))
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
result = []
for i in range(Q):
  l, r = map(int, input().split())
  result.append(S[l-1:r].count('AC'))
[print(i) for i in result]

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
  t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for _ in range(q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])
### BUGGY CODE ###

a,b,c,d,e,f = map(int, input().split())
con = list()
s = list()
for x in range(31):
    for y in range(31):
        for v in range(1501):
            if x == y == 0:
                continue
            else:
                w1 = (f-(100*a*x + 100*b*y + c*v))//d
#                 w2 = (100*a*x + 100*b*y -c*v)//d
                w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d)
                w = min(w1,w3)
                con1 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w)
                con.append(con1)
                s.append([x,y,v,w])
conm = max(con)
conin =con.index(conm)
t = s[conin]
# print(t)
ans1 = 100*a*t[0] + 100*b*t[1] + c*t[2] + d*t[3]
ans2 = c*t[2] + d*t[3]
print(ans1,ans2)


### FIXED CODE ###

a,b,c,d,e,f = map(int, input().split())
s = [0,0,0,0]
con1 = 0
for x in range(31):
    for y in range(31):
        for v in range(1501):
            if x == y == 0:
                continue
            else:
                w1 = (f-(100*a*x + 100*b*y + c*v))//d
                w2 = (100*a*x + 100*b*y -c*v)//d
                w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d)
                w = min(w1,w2,w3)
                con2 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w)
                if con1 <= con2 and w >= 0:
                    con1 = con2
                    s = [x,y,v,w]
                else:
                    continue

ans1 = 100*a*s[0] + 100*b*s[1] + c*s[2] + d*s[3]
ans2 = c*s[2] + d*s[3]
print(ans1,ans2)
### BUGGY CODE ###

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

while len(A) > 1:
    b = [0] * len(A)
    m = A[0]
    b[0] = m
    for n in range(1, len(A)):
        b[n] = A[n] % m
    A = list(set(b))
    if A[0] == 0:
        A = A[1:]
print(A[0])


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
num = len(A)

while num > 1:
    a = min(A)
    j = 0
    flag = True
    for n in range(num):
        if A[n] == a and flag:
            A[j] = a
            j += 1
            flag = False
        else:
            b = A[n] % a
            if b > 0:
                A[j] = b
                j += 1
    num = j

print(A[0])
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
def nibuta(a,x):
    h=len(a)
    if a[0]>=x:
        return 0
    elif a[h-1]<x:
        return h
    else:
        lo=0
        up=h-1
        while up-lo!=1:
            if a[(lo+up)//2]>=x:
                up=(lo+up)//2
            else:
                lo=(lo+up)//2
        if a[up]>=x:
            return lo+1
        else:
            return up+1
s=0
for i in range(n-2):
    a1=l[i]
    for j in range(i+1,n-1):
        k=a1+l[j]
        s=s+nibuta(l[j+1:],k)
print(s)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
def nibuta(a,x):
    h=len(a)
    if a[0]>=x:
        return 0
    elif a[h-1]<x:
        return h
    else:
        lo=-1
        up=h-1
        while up-lo>1:
            if a[(lo+up)//2]>=x:
                up=(lo+up)//2
            else:
                lo=(lo+up)//2
        if a[up]>=x:
            return lo+1
        else:
            return up+1
s=0
for i in range(n-2):
    a1=l[i]
    for j in range(i+1,n-1):
        k=a1+l[j]
        s=s+nibuta(l[j+1:],k)
print(s)
### BUGGY CODE ###

# 初期入力
N = int(input())
#A = list(map(int, input().split()))
A = list(map(int, input().split()))
#　1の左側は砕く、以降数字が大きくなるほど右側にあればいいが、順番が違うと砕く必要あり。
from copy import deepcopy
x = 0
y =0
z = []
for i in range(1,N+1):
    if i in A[x:]:
        y = A[x:].index(i ) 
        z.append(y)
        x += y
        #if y==0:
         #   break

    else:
        y = -1
        break
#
renga_kudaku = 0
if len(z) ==0 and y==-1:
    renga_kudaku = -1
elif len(z) ==0:
    renga_kudaku = 0
else:
    renga_kudaku=N-len(z) # 求める物＝全体ー残る要素数、zは残る文字の配列
print(renga_kudaku)

### FIXED CODE ###

#初期入力
import sys
N = int(input())
A=[int(i) for i in input().split()]
#


if 1 not in A:
    print(-1)
    exit
else:
    i=1 #探す数字
    brick_remain =set() #「1」は入っていること上記で確かめた
    for a in A:
        if a ==i:
            brick_remain.add(a)
            i +=1
    brick_destroy = N - len(brick_remain)       
    print(brick_destroy)
### BUGGY CODE ###

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

ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N)]
for i, (ai, bi) in enumerate(ab):
    graph[ai - 1].append(bi - 1)
    graph[bi - 1].append(ai - 1)

from collections import deque
    
c = [0] * N
for j, (pj, xj) in enumerate(px):
    c[pj - 1] += xj
    
ans = [None] * N
ans[0] = c[0]
q_0 = deque([(c[0], 0)])
while len(q_0) > 0:
    score, src = q_0.popleft()
    # print("#", score, src)
    ans[src] = score
    for dst in graph[src]:
        if ans[dst] == None:
            q_0.append((score + c[dst], dst))

print(' '.join(map(str, ans)))

### FIXED CODE ###

N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N)]
for ai, bi in ab:
    graph[ai - 1].append(bi - 1)
    graph[bi - 1].append(ai - 1)

parent = [None] * N
parent[0] = 0

score = [0] * N
for pi, xi in px:
    score[pi - 1] += xi

ans = [None] * N

from collections import deque

q = deque([(0, 0)])
while len(q) > 0:
    src, score_tmp = q.popleft()
    score_tmp += score[src]
    ans[src] = score_tmp
    for dst in graph[src]:
        if ans[dst] != None: continue
        q.append((dst, score_tmp))

print(' '.join(map(str, ans)))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
print = sys.stdout.write

def main():
    def bit_add(arr, n, i, x):
        while i <= n:
            arr[i] += x
            i += i & -i

    def bit_sum(arr, i):
        result = 0
        while i > 0:
            result += arr[i]
            i ^= i & -i
        return result

    N, Q = map(int, input().split())
    C = list(map(int,input().split()))

    L, R = [], []
    for _ in range(Q):
        l, r = map(int, input().split())
        L.append(l-1);R.append(r-1)

    just_left = {}
    segments = []
    for i in range(N):
        c = C[i]
        if c in just_left:
            segments.append((i, 0, just_left[c], 0))
        just_left[c] = i

    for i in range(Q):
        segments.append((R[i], 1, L[i], i))

    segments.sort()
    bit = [0] * (N+2)
    ans = [0] * Q

    for r, tp, l, i in segments:
        if tp == 0:
            bit_add(bit, N + 2, l + 2, 1)
        else:
            base = r - l + 1
            ans[i] = base - (bit_sum(bit, r + 2) - bit_sum(bit, l + 1))

    print("\n".join(map(str,ans)))
main()

### FIXED CODE ###

import numpy as np

def solve(inp):
    def bit_add(arr, n, i, x):
        while i <= n:
            arr[i] += x
            i += i & -i

    def bit_sum(arr, i):
        result = 0
        while i > 0:
            result += arr[i]
            i ^= i & -i
        return result

    N, Q = inp[:2]
    C = inp[2: 2+N]
    L, R = inp[2+N::2] - 1, inp[3+N::2] - 1

    just_left = {}
    segments = []
    for i in range(N):
        c = C[i]
        if c in just_left:
            segments.append((i, 0, just_left[c], 0))
        just_left[c] = i

    for i in range(Q):
        segments.append((R[i], 1, L[i], i))

    segments.sort()
    bit = np.zeros(N + 2, dtype=np.int64)
    ans = np.zeros(Q, dtype=np.int64)

    for r, tp, l, i in segments:
        if tp == 0:
            bit_add(bit, N + 2, l + 2, 1)
        else:
            base = r - l + 1
            ans[i] = base - (bit_sum(bit, r + 2) - bit_sum(bit, l + 1))

    return ans

def main():
    inp = np.fromstring(open(0).read(), dtype=np.int64, sep=' ')
    ans = solve(inp)
    print("\n".join(map(str,ans)))
    

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()

if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import solve
    main()
### BUGGY CODE ###


loopnum = int(input())
cnt = 0
for i in range(loopnum):

	chknum = int(input())

	for j in range(2,chknum):
		if chknum % j == 0:
			break
	else:
		cnt += 1

print(cnt)



### FIXED CODE ###

import math

loopnum = int(input())
cnt = 0
for i in range(loopnum):

	chknum = int(input())
	rootnum = int(math.sqrt(chknum))

	for j in range(2,rootnum+1):
		if chknum % j == 0:
			break
	else:
		cnt += 1

	# TLE
	#for j in range(2,chknum):
	#	if chknum % j == 0:
	#		break
	#else:
	#	cnt += 1

print(cnt)
### BUGGY CODE ###

N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))+[0]
p=100

if K<=p:    
    for i in range(K):
        B=[0]+[0]*N+[0]
        for j in range(1,N+1):
            left  = max(0,j-A[j])
            right = min(N+1,j+A[j]+1)
            B[left]  += 1
            B[right] -= 1
        A[0]=B[0]
        for k in range(1,N+1):
            A[k]=A[k-1]+B[k]
else:
    A=[N]*(N+2)
print(*A[1:N+1])

### FIXED CODE ###

N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))+[0]
p=50

if K<=p:    
    for i in range(K):
        B=[0]+[0]*N+[0]
        for j in range(1,N+1):
            left  = max(0,j-A[j])
            right = min(N+1,j+A[j]+1)
            B[left]  += 1
            B[right] -= 1
        A[0]=B[0]
        for k in range(1,N+1):
            A[k]=A[k-1]+B[k]
else:
    A=[N]*(N+2)
print(*A[1:N+1])
### BUGGY CODE ###

n,x = map(int,input().split())
li = list(map(int,input().split()))

res = []

s = 10**10

for i in range(n):
    s = abs(li[i] - x)
    res.append(s)
    
s = min(res)
    
while True:
    for i in range(n):
        if res[i]%s != 0:
            break
    else:
        print(s)
        exit()
        
    s -= 1

### FIXED CODE ###

n,x = map(int,input().split())
li = list(map(int,input().split()))

res_abs = []
res = []

s = 10**10

for i in range(n):
    s = abs(li[i] - x)
    res_abs.append(s)
    
    s = li[i] - x
    res.append(s)
    
res.sort()

temp = 10**10

for i in range(n-1):
    temp = min(temp, res[i+1] - res[i])

    
s = min(min(res_abs), temp)
    
while True:
    for i in range(n):
        if res_abs[i]%s != 0:
            break
    else:
        print(s)
        exit()
        
    s -= 1
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)

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

memo = {}

def dp(i, cur):
  if (i, cur) in memo:
    return memo[(i, cur)]
  if i==n-1:
    return cur
  if i == n-2:
    cur += abs(f[i] - f[i+1])
    return dp(i+1, cur)
  else:
    ret = min(dp(i+1, cur + abs(f[i] - f[i+1])), dp(i+2, cur + abs(f[i] - f[i+2])))
    memo[(i, cur)] = ret
    return ret
print(dp(0, 0))

### FIXED CODE ###

n = int(input())
arr = list(map(int, input().split()))
if n == 2:
    print(abs(arr[0] - arr[1]))
    exit()
dp = [10 ** 9 for _ in range(n)]
dp[0] = abs(arr[0] - arr[1])
dp[1] = min(abs(arr[2] - arr[0]), abs(arr[2] - arr[1]) + dp[0])

for i in range(3, n):
    dp[i - 1] = min(
        abs(arr[i] - arr[i - 1]) + dp[i - 2], abs(arr[i] - arr[i - 2]) + dp[i - 3]
    )

# dp[2] = min(abs(arr[3] - arr[2]) + dp[1], abs(arr[3] - arr[1]) + dp[0])
# dp[3] = min(abs(arr[4] - arr[3]) + dp[2], abs(arr[4] - arr[2]) + dp[1])
# dp[4] = min(abs(arr[5] - arr[4]) + dp[3], abs(arr[5] - arr[3]) + dp[2])

print(dp[-2])
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
ans=1
for i in range(0,n):
  ans*=A[i]
if ans>10**18:
  print(-1)
  exit()
print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
ans=1
for i in range(n):
  if A[i]==0:
    print(0)
    exit()
for i in range(n):
  if len(str(A[i]))>19:
    print(-1)
    exit()
  ans*=A[i]
  if ans>10**18:
    print(-1)
    exit()
print(ans)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
AC = []
for i in range(N-1):
  if S[i]+S[i+1] == "AC":
    AC.append(i+1.5)

for j in range(Q):
  l,r = map(int,input().split())
  cnt = 0
  for k in AC:
    if l < k < r:
      cnt += 1
    if r < k:
      break
  print(cnt)

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
t = [0]*(N+1)

for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
  
for j in range(Q):
  l,r = map(int,input().split())
  print(t[r-1] - t[l-1])
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
for j in range(K):
    h.append(0)
INF = float('inf')
dp = [INF] * (N+K)
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]))
print(dp[N-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
for j in range(K):
    h.append(0)
INF = float('inf')
dp = [INF] * (N+K)
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]))
print(dp[N-1])
### BUGGY CODE ###

N=int(input())
ans=[]
for i in range(N):
    S=input()
    if S not in ans:
        ans.append(S)
print(len(ans))

### FIXED CODE ###

N=int(input())
ans=set()
for i in range(N):
    S=input()
    ans.add(S)
print(len(ans))
### BUGGY CODE ###

import sys
INF=100000000
cost_value=1000000000000
def frog(i,K,h,dp):
    global INF,cost_value
    if dp[i]!=INF:
        return dp[i]
    else:
        cost=cost_value
        for k in range(1,K+1):
            if i-k-1>=0:
                x=frog(i-k,K,h,dp)+abs(h[i-1]-h[i-k-1])
                if cost>x:
                    cost=x
        dp[i]=cost
        return dp[i]
sys.setrecursionlimit(INF)
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[INF for i in range(N+1)]
dp[1]=0
dp[2]=abs(h[1]-h[0])
print(frog(N,K,h,dp))


### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
h=list(map(int,input().split()))
h=np.array(h)
cost=np.zeros(N+1)
cost[1]=0
cost[2]=abs(h[1]-h[0])
for i in range(3,N+1):
    x=1 if i-K<=1 else i-K
    cost[i]=(cost[x:i]+abs(h[i-1]-h[x-1:i-1])).min()
print(int(cost[N]))
### BUGGY CODE ###

d,g=map(int,input().split())
g=g//100
pc=[list(map(int,input().split())) for i in range(d)]
P=0
C=0#合計
for i in range(d):
    pc[i][1]=pc[i][1]//100
    C=(C+pc[i][1]+pc[i][0]*(i+1))
    P+=pc[i][0]
dp=[0]*(C+1)
#print(C)
for i in range(d):
    dp_sub=[0]*(C+1)
    for j in range(C+1):
        if j==0:
            for k in range(1,pc[i][0]+1):
                if k!=pc[i][0]:
                    dp_sub[k*(i+1)]=k
                else:
                    dp_sub[k*(i+1)+pc[i][1]]=k
        elif dp[j]!=0:
            for k in range(1,pc[i][0]+1):
                if k!=pc[i][0]:
                    if dp_sub[j+k*(i+1)]!=0:
                        dp_sub[j+k*(i+1)]=min(dp[j]+k,dp_sub[j+k*(i+1)])
                    else:
                        dp_sub[j+k*(i+1)]=dp[j]+k
                else:
                    #print(j+k*(i+1)+pc[i][1])
                    if dp_sub[j+k*(i+1)+pc[i][1]]!=0:
                        dp_sub[j+k*(i+1)+pc[i][1]]=min(dp[j]+k,dp_sub[j+k*(i+1)+pc[i][1]])
                    else:
                        dp_sub[j+k*(i+1)+pc[i][1]]=dp[j]+k
    #print(dp_sub)
    for j in range(C+1):
        if dp_sub[j]!=0:
            if dp[j]==0:
                dp[j]=dp_sub[j]
            else:
                dp[j]=min(dp[j],dp_sub[j])
m=P
for i in range(g,C+1):
    if dp[i]!=0:
        m=min(m,dp[i])
print(m)
#print(dp)


### FIXED CODE ###

import math
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=10000000000000000000
for i in range(1<<d):
    s=0
    ans_=0
    for j in range(d):
        if (i>>j)&1:
            s+=(pc[j][1]+pc[j][0]*100*(j+1))
            ans_+=pc[j][0]
    #print(s,ans_)
    if s>=g:
        ans=min(ans,ans_)
    else:
        for j in range(d-1,-1,-1):
            if not((i>>j)&1):
                if s+(pc[j][0]*100*(j+1))>=g:
                    h=-((s-g)//(100*(j+1)))
                    s+=(h*100*(j+1))
                    ans_+=h
                    ans=min(ans,ans_)
                    break
                else:
                    break
print(ans)
#ansとans_
#謎のWA
### BUGGY CODE ###

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k 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 *= int(numerator[k])

    return result
n, a, b = map(int,input().split())
if n == 2:
  print(0)
else:
  total = 2 ** n -1
  total  = total - cmb(n,a) -cmb(n,b)
  print(total % (10 ** 9 + 7))


### FIXED CODE ###

N, a, b = map(int,input().split())
p = pow(10,9) + 7
def comb(n,r):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
print((pow(2,N, p) - 1 - comb(N,a) - comb(N,b)) % p)
### BUGGY CODE ###

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

cnt=[]
for i in range(Q):
    ans=0
    l,r = map(int,input().split())
    s = S[l-1:r]
    j = 0
    while j+2 <= len(s):
        if s[j:j+2] == 'AC':
            ans += 1
        j += 1
    cnt.append(ans)

for answer in cnt:
    print (answer)

### FIXED CODE ###

from itertools import accumulate

N,Q = map(int,input().split())
S = input()
A = [list(map(int,input().split())) for i in range(Q)]

flg=[]
for i in range(N-1):
    s = S[i:i+2] 
    if s == 'AC':
        flg.append(1)
    else:
        flg.append(0)

flg2 = list(accumulate([0]+flg))

for a in A:
    print (flg2[a[1]-1]-flg2[a[0]-1])
### BUGGY CODE ###

N, K= map(int, input().split())
h = list(map(int, input().split()))

for i in range(K):
  h.append(float('inf'))

dp = [0]
for i in range(N+K):
  dp.append(float('inf'))

for i in range(N):
  for j in range(1,K+1):
    
    dp[i+j] = min(dp[i+j],dp[i] + abs(h[i]-h[i+j]))
    #print(dp)

print(dp[N-1])

### FIXED CODE ###

N, K= map(int, input().split())
h = list(map(int, input().split()))

for i in range(K):
  h.append(float('inf'))

dp = [0]
for i in range(N+K):
  dp.append(float('inf'))

for i in range(N):
  for j in range(1,K+1):
    
    dp[i+j] = min(dp[i+j],dp[i] + abs(h[i]-h[i+j]))
    #print(dp)

print(dp[N-1])
### BUGGY CODE ###

H = int(input())
i = 0

while True:
    H //= 2
    i += 1
    if H == 1:
        break

result = 0
for i in range(i+1):
    result += 2**i

print(result)

### FIXED CODE ###

H = int(input())
i = 0
result = 0
 
while True:
    result += 2**i
    H //= 2
    i += 1
    if H == 0:
        break
 
print(result)
### BUGGY CODE ###

from collections import deque
N,M = map(int, input().split())
AB_s = [list(map(int, input().split())) for _ in range(M)]

answer = [0] * N
queue = deque([1])
answer[0] = N

while len(queue) > 0:
    P = queue.popleft()
    POPS = []
    for i, AB in enumerate(AB_s):
        # P の含まれるパスだったら
        if P in AB:
            # P じゃない方が Q
            Q = AB[0] if AB[1] == P else AB[1]
            # 到達してなかったら道標を置く
            if answer[Q-1] == 0:
                answer[Q-1] = P
                queue.append(Q)
            POPS.append(i)
    for POP in POPS[::-1]:
        AB_s.pop(POP)

if min(answer) == 0:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(answer[i])


### FIXED CODE ###

from collections import deque
N,M = map(int, input().split())
AB_s = [list(map(int, input().split())) for _ in range(M)]

MAP = [[] for _ in range(N)]
for AB in AB_s:
    A, B = map(int, AB)
    MAP[A-1].append(B)
    MAP[B-1].append(A)
answer = [0] * N
queue = deque([1])
answer[0] = N
while len(queue) > 0:
    P = queue.popleft()
    if True:
        for Q in MAP[P-1]:
            if answer[Q-1] == 0:
                answer[Q-1] = P
                queue.append(Q)
if min(answer) == 0:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(answer[i])
### BUGGY CODE ###

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

h,w,m=nii()

h_bomb=[0 for i in range(h)]
w_bomb=[0 for i in range(w)]

l=[]
for i in range(m):
  th,tw=nii()
  th-=1
  tw-=1
  h_bomb[th]+=1
  w_bomb[tw]+=1
  l.append([th,tw])

h_max=max(h_bomb)
w_max=max(w_bomb)

h_cand=[]
w_cand=[]

for i in range(len(h_bomb)):
  if h_bomb[i]==h_max:
    h_cand.append(i)

for i in range(len(w_bomb)):
  if w_bomb[i]==w_max:
    w_cand.append(i)

for i in h_cand:
  for j in w_cand:
    if [i,j] not in l:
      print(h_max+w_max)
      exit()

print(h_max+w_max-1)

### FIXED CODE ###

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

h,w,m=nii()

h_bomb=[0 for i in range(h)]
w_bomb=[0 for i in range(w)]

l=set()
for i in range(m):
  th,tw=nii()
  th-=1
  tw-=1
  h_bomb[th]+=1
  w_bomb[tw]+=1
  l.add((th,tw))

h_max=max(h_bomb)
w_max=max(w_bomb)

h_cand=[]
w_cand=[]

for i in range(len(h_bomb)):
  if h_bomb[i]==h_max:
    h_cand.append(i)

for i in range(len(w_bomb)):
  if w_bomb[i]==w_max:
    w_cand.append(i)

for i in h_cand:
  for j in w_cand:
    if (i,j) not in l:
      print(h_max+w_max)
      exit()

print(h_max+w_max-1)
### BUGGY CODE ###

n = int(input())
l = list(map(int,input().split()))
ans = 0

for i in range(10000, 10000000)[::-1]:
    x = 0
    for j in l:
        x += i%j
    if x > ans:
        ans = x

print(ans)

### FIXED CODE ###

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

print(sum(li)-n)