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

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

B = []

for a in A:
    if a in B:
        B.remove(a)
    else:
        B.append(a)

print(len(B))

### FIXED CODE ###

# 要素であるかの確認は配列じゃなくsetを使う
# setはハッシュで実装されているため

N = int(input())
s = set()
 
for i in range(N):
    a=int(input())
    if a in s:
        s.remove(a)
    else:
        s.add(a)
 
print(len(s))
### BUGGY CODE ###

a, b, c, d = map(int, input().split())
kai_a = a // d
kai_c = c // b
amari_a = a % d
amari_c = c % b

while a > 0:
    while c > 0:
        c -= b
        if c <= 0:
            print('Yes')
            break
        else:
            a -= d
            if a <= 0:
                print('No')
                break

### FIXED CODE ###

def main():
    a, b, c, d = map(int, input().split())
    kai_a = a // d
    kai_c = c // b
    amari_a = a % d
    amari_c = c % b
    
    if kai_a > kai_c:
        print('Yes')
    elif kai_a == kai_c:
        if amari_c == 0:
            print('Yes')
        elif amari_a == 0:
            print('No')
        else:
            print('Yes')
    else:
        if amari_c == 0 and amari_a > 0:
            print('Yes')
        else:
            print("No")

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

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

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
flag = 0
ans = 1
for i in range(N):
    if flag == 0:
        ans *= A[i]
    if ans > 10**18 and flag != 2:
        flag = 1
    if A[i] == 0:
        flag = 2
if flag == 0:
    print(ans)
elif flag == 1:
    print(-1)
else:
    print(0)
### BUGGY CODE ###

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

def f(x):
    return (a*(x%b)-(a*b)%b)//b

ans = 0
for i in range(min(n+1,b+1)):
    ans = max(f(i),ans)
print(ans)

### FIXED CODE ###

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

mx = a*n//b
if n//b < 1:
    print(mx)
else:
    x = (a*b-a)//b
    print(x)
### BUGGY CODE ###

N = int(input())
P = [int(input()) for _ in range(N)]
maxlen = 1
tmplen = 1
indexls = [P.index(i+1) for i in range(N)]
for i in range(1,N):
    if indexls[i] > indexls[i-1]:
        tmplen += 1
        maxlen = max(maxlen,tmplen)
    else:
        tmplen = 1
print(N-maxlen)

### FIXED CODE ###

N = int(input())
P = []
indexls = [0]*N
for i in range(N):
    tmp = int(input())
    P.append(tmp)
    indexls[tmp-1] = i
maxlen = 1
tmplen = 1
for i in range(1,N):
    if indexls[i] > indexls[i-1]:
        tmplen += 1
        maxlen = max(maxlen,tmplen)
    else:
        tmplen = 1
print(N-maxlen)
### BUGGY CODE ###

import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
lstp = []
for i in range(n-k+1):
    lstp.append(p[i:i+k])
l = []
for ls in lstp:
    num = 0
    for j in range(k):
        num  += 0.5*(ls[j]+1)
    l.append(num)
print("{:.10f}".format(max(l)))

### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))
wa = sum(p[0:k])
next_wa = wa
for i in range(n-k):
    next_wa = next_wa - p[i] + p[i+k]
    if  next_wa > wa:
        wa = next_wa
print(0.5*(wa+k))
### BUGGY CODE ###

from scipy.sparse import csr_matrix #pypyだとエラーになるので、pythonを使うこと
from scipy.sparse.csgraph import shortest_path

import sys
def input():
	return sys.stdin.readline().strip()

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

graph = csr_matrix((N, N))

for i in range(M):
	A, B, C = list(map(int, input().split()))
	graph[A - 1, B - 1] = C
	graph[B - 1, A - 1] = C


dist = shortest_path(graph, method='FW', directed=False)
graph2 = csr_matrix((N, N))
for i in range(N):
	for j in range(N):
		if dist[i, j] <= L:
			graph2[i, j] = 1
graph2 = csr_matrix(graph2)
num = shortest_path(graph2, method="FW", directed=False)


Q = int(input())
for q in range(Q):
	s, t = list(map(int, input().split()))
	if num[s - 1][t - 1] < 10000000:
		print(int(num[s - 1][t - 1] - 1))
	else:
		print(-1)

### FIXED CODE ###


import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter

import sys
def input():
	return sys.stdin.readline().strip()

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

graph = [[] for _ in range(N)]

for i in range(M):
	A, B, C = list(map(int, input().split()))
	if C <= L:
		graph[A - 1].append((B - 1, C))
		graph[B - 1].append((A - 1, C))

num_matrix = [[0]*N for i in range(N)]


for start in range(N):
	dist = [(1000000, 0)]*N
	que = []
	heapq.heappush(que, (0, 0, start))
	dist[start] = (0, 0)
	while len(que) > 0:

		node = heapq.heappop(que)
		#print(start, que, node)
		if node[0] == dist[node[2]][0] and node[1] == dist[node[2]][1]:
			#print(1)
			for edge in graph[node[2]]:
				#print(edge)
				#print(edge[1] + dist[node[2]][1] )
				if edge[1] + dist[node[2]][1] > L:
					next_dist = (dist[node[2]][0] + 1, edge[1], edge[0])
				else:
					next_dist = (dist[node[2]][0], dist[node[2]][1] + edge[1], edge[0])
				if dist[edge[0]][0] > next_dist[0]:
					dist[next_dist[2]] = (next_dist[0], next_dist[1])
					heapq.heappush(que, next_dist)
				elif dist[edge[0]][0] == next_dist[0] and dist[edge[0]][1] > next_dist[1]:
					heapq.heappush(que, next_dist)
					dist[next_dist[2]] = (next_dist[0], next_dist[1])
	for i in range(N):
		num_matrix[start][i] = dist[i][0]

#print(num_matrix)

Q = int(input())
for q in range(Q):
	s, t = list(map(int, input().split()))
	if num_matrix[t - 1][s - 1] < 1000:
		print(num_matrix[t - 1][s - 1])
	else:
		print(-1)
### BUGGY CODE ###

import itertools

num = int(input())
l = list(map(int, input().split()))

total = 0
for i in range(1, num+1):
    for diff_num in itertools.combinations(l, i):
        diff_num = sorted(list(diff_num))
        for j in range(len(diff_num)):
            total += diff_num[j] * (len(diff_num) - j)

total *= 2 ** num
ans = total % (10 ** 9 + 7)
print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!

num = int(input())
costs = sorted(list(map(int, input().split())), reverse = True)

total = 0
for i in range(1, num+1):
    total += (i + 1) * costs[i-1]
ans = (total * (4 ** (num - 1))) % (10 ** 9 + 7)
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
A = map(int, raw_input().split())

m_fact = {}
def fact(n):
    if n in m_fact:
        return m_fact[n]
    if n == 1:
        m_fact[n] = 1
        return 1
    m_fact[n] = fact(n - 1) * n
    return m_fact[n]

m_rev = {}
def rev_mod(n):
    if n in m_rev:
        return m_rev[n]
    p = MOD - 2
    ret = 1
    p_cur = n
    while p > 0:
        if p % 2:
            ret *= p_cur
            ret %= MOD
        p_cur *= p_cur
        p_cur %= MOD
        p /= 2
    m_rev[n] = ret
    return ret

S = [0] * (N + 2)
S2 = [0] * (N + 2)

for i in range(1, N):
    num = (fact(N) * rev_mod(i + 1)) % MOD
    S[0] += num
    S[0] %= MOD
    S[i] -= num
    S[i] %= MOD
    S[N] -= num
    S[N] %= MOD
    S[N - i] += num
    S[N - i] %= MOD

S[0] += fact(N)
S[0] %= MOD
S[N] -= fact(N)
S[N] %= MOD

for i in range(N):
    S[i + 1] += S[i]
    S[i + 1] %= MOD

for i in range(1, N - 1):
    num = (fact(N) * rev_mod(i + 1) * rev_mod(i + 2) * 2) % MOD
    wid = min(i, N - 1 - i)
    S2[1] += num
    S2[1] %= MOD
    S2[wid + 1] -= num
    S2[wid + 1] %= MOD
    S2[N - wid] -= num
    S2[N - wid] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

for i in range(N):
    S[i] *= A[i]
    S[i] %= MOD
    S2[i] *= A[i]
    S2[i] %= MOD

print (sum(S[:N]) + sum(S2[:N])) % MOD

### FIXED CODE ###

#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
A = map(int, raw_input().split())

m_fact = {}
def fact(n):
    if n in m_fact:
        return m_fact[n]
    if n == 1:
        m_fact[n] = 1
        return 1
    m_fact[n] = (fact(n - 1) * n) % MOD
    return m_fact[n]

m_rev = {}
def rev_mod(n):
    if n in m_rev:
        return m_rev[n]
    p = MOD - 2
    ret = 1
    p_cur = n
    while p > 0:
        if p % 2:
            ret *= p_cur
            ret %= MOD
        p_cur *= p_cur
        p_cur %= MOD
        p /= 2
    m_rev[n] = ret
    return ret

S = [0] * (N + 2)
S2 = [0] * (N + 2)

for i in range(1, N):
    num = (fact(N) * rev_mod(i + 1)) % MOD
    S[0] += num
    S[0] %= MOD
    S[i] -= num
    S[i] %= MOD
    S[N] -= num
    S[N] %= MOD
    S[N - i] += num
    S[N - i] %= MOD

S[0] += fact(N)
S[0] %= MOD
S[N] -= fact(N)
S[N] %= MOD

for i in range(N):
    S[i + 1] += S[i]
    S[i + 1] %= MOD

for i in range(1, N - 1):
    num = (fact(N) * rev_mod(i + 1) * rev_mod(i + 2) * 2) % MOD
    wid = min(i, N - 1 - i)
    S2[1] += num
    S2[1] %= MOD
    S2[wid + 1] -= num
    S2[wid + 1] %= MOD
    S2[N - wid] -= num
    S2[N - wid] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

ans = 0
for i in range(N):
    ans += S[i] * A[i]
    ans += S2[i] * A[i]
    ans %= MOD

print ans
### BUGGY CODE ###

# D
import numpy as np

N, K = list(map(int, input().split()))
p = np.array(list(map(int, input().split())))

ans = 0
for i in range(0, N-K+1):
    ans_tmp = np.sum(p[i:i+K])
    ans = max(ans, ans_tmp)

ans = (ans+K)/2

print(ans)

### FIXED CODE ###

# D

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

ans = sum(p[0:K])
ans_tmp = ans
for i in range(K, N):
#    print(p)
#    print(-p[i-K] + p[K])
    ans_tmp = ans_tmp - p[i-K] + p[i]
#    print(ans_tmp)
    ans = max(ans, ans_tmp)

ans = (ans+K)/2

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

n=10000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
#p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(input())
    if n==0: break
    for i in range(n,2,-1):
        if (p[i],p[i-2],p[i-6],p[i-8])==(1,1,1,1):
            print(i)
            break

### FIXED CODE ###

n=10000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
#p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(input())
    if n==0: break
    if n<19:print(13)
    else:
        for i in range((n+1)//10*10-1,2,-10):
            if (p[i],p[i-2],p[i-6],p[i-8])==(1,1,1,1):
                print(i)
                break
### BUGGY CODE ###

a = int(input())
b = 1
c = []
for i in range(a):
    c.append(b)
    b += 1

for I in range(a):
    if c[I]%15 == 0:
        c.remove(c[I])
        c.insert(I,'a')

    elif c[I]%5 == 0:
        c.remove(c[I])
        c.insert(I,'a')
    
    elif c[I]%3 == 0:
        c.remove(c[I])
        c.insert(I,'a')
        
    else:
        continue


D = 0
for q in range(a):
    if c[q] == 'a':
        continue
    elif c[q] != 'a':
        D = D + c[q]
print(D)

### FIXED CODE ###

a = int(input())
d = 1
D = 0
for I in range(a):
    if d%3 == 0:
        d += 1
    
    elif d%5 == 0:
        d += 1
        
    else:
        D = D + d
        d += 1
print(D)
### BUGGY CODE ###

n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
count = 0
for a in t:
    left = 0
    right = n - 1
    while left <= right:
        mid = (right + left) // 2
        if a == s[mid]:
            count += 1
            break
        elif a < s[mid]:
            right = mid
        else :
            left = mid + 1

print(count)



### FIXED CODE ###

n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
count = 0
for a in t:
    left = 0
    right = n
    while left < right:
        mid = (right + left) // 2
        if a == s[mid]:
            count += 1
            break
        elif a < s[mid]:
            right = mid
        else :
            left = mid + 1

print(count)
### BUGGY CODE ###


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

s_max = 0
for j in range(N - K + 1):
    s = 0
    for i in range(K):
        s += (p[i+j] + 1) / 2

    if s_max < s:
        s_max = s

print(s_max)

### FIXED CODE ###


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


s = sum(p[0:K])
s_max = s

for i in range(N-K):
    s = s -p[i] + p[i+K]

    if s_max < s:
        s_max = s

print((s_max+K)/2)
### BUGGY CODE ###

INF = 1000000000

def BellmanFord_edge(s, v, edge):
    dp = [INF] * v
    dp[s] = 0
    for i in range(0, v):
        for fr, to, d in edge:
            if dp[fr] == INF:
                continue
            if dp[to] > dp[fr] + d:
                dp[to] = dp[fr] + d
                if i == v - 1:
                    return -1
    return dp

def BellmanFord_graph(s, v, graph):
    dp = [INF] * v
    dp[s] = 0
    for i in range(0, v):
        for k in range(0, v):
            dp1 = [dp[k] + graph[k][j] if dp[k] != INF and graph[k][j] != INF and dp[j] > dp[k] + graph[k][j]
                  else dp[j]
                  for j in range(0, v) ]
            if dp1 != dp and i == v - 1:
                return -1
            dp = dp1
    return dp

dp = []
line = input()
v, e = list(map(int, line.split()))
graph = [ [INF] * v for _ in range(0, v)]
edge = []
for _ in range(0, e):
    line = input()
    s, t, d = list(map(int, line.split()))
    edge += [[s, t, d]]
    graph[s][t] = d
for s in range(0, v):
#    dp = BellmanFord(s, v, graph)
    dp = BellmanFord_edge(s, v, edge)
    if dp == -1:
        print("NEGATIVE CYCLE")
        break
    else:
        print(" ".join(map(str, [dp[t] if dp[t] != INF else "INF" for t in range(0, v)])))


### FIXED CODE ###

INF = 999999999999

def BellmanFord_edge(s, v, edge):
    dp = [INF] * v
    dp[s] = 0
    for i in range(0, v):
        dp1 = dp[:]
        for fr, to, d in edge:
            if dp[fr] == INF:
                continue
            if dp[to] > dp[fr] + d:
                dp[to] = dp[fr] + d
                if i == v - 1:
                    return -1
        if dp == dp1:
            break
    return dp

def BellmanFord_graph(s, v, graph):
    dp = [INF] * v
    dp[s] = 0
    for i in range(0, v):
        for k in range(0, v):
            dp1 = [dp[k] + graph[k][j] if dp[k] != INF and graph[k][j] != INF and dp[j] > dp[k] + graph[k][j]
                  else dp[j]
                  for j in range(0, v) ]
            if dp1 != dp and i == v - 1:
                return -1
            dp = dp1
    return dp

dp = []
line = input()
v, e = list(map(int, line.split()))
graph = [ [INF] * v for _ in range(0, v)]
edge = []
for _ in range(0, e):
    line = input()
    s, t, d = list(map(int, line.split()))
    edge += [[s, t, d]]
    graph[s][t] = d
for s in range(0, v):
#    dp = BellmanFord(s, v, graph)
    dp = BellmanFord_edge(s, v, edge)
    if dp == -1:
        print("NEGATIVE CYCLE")
        break
    else:
        print(" ".join(map(str, [dp[t] if dp[t] != INF else "INF" for t in range(0, v)])))
### BUGGY CODE ###

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

for i in range(1,N + 1):
  print(works.count(i))

### FIXED CODE ###

N = int(input())
works = list(map(int, input().split()))
ans = [0] * (N + 1)
 
for i in range(0,N - 1):
  
  ans[works[i]] += 1

ans.pop(0)
for i in ans:
  print(i)
### BUGGY CODE ###

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

f=1
w=[]
d=[0]*(m+2)
t=[0]
chk=n
for i in range(m+1):
    f=pow(2,i)
    p=pow(x,f,m)
    if d[p]: break
    d[p]=1
    w.append(p)
    t.append(t[-1]+p)
    #f*=2
    chk-=1
    if chk==0:
        print(t[-1])
        exit()
ans=0
a=w.index(p)
ans+=t[a]
n-=a
loo=len(w)-a
if n%loo==0:
    ans+=(t[-1]-t[a])*(n//loo)
else:
    ans+=(t[-1]-t[a])*(n//loo)
    ans+=t[a+n%loo]-t[a]
print(ans)


### FIXED CODE ###

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

f=1
w=[]
d=[0]*(m+2)
t=[0]
chk=n
p=x
for i in range(m+1):
    if i!=0: p=p*p%m
    if d[p]: break
    d[p]=1
    w.append(p)
    t.append(t[-1]+p)
    #f*=2
    chk-=1
    if chk==0:
        print(t[-1])
        exit()
ans=0
a=w.index(p)
ans+=t[a]
n-=a
loo=len(w)-a
if n%loo==0:
    ans+=(t[-1]-t[a])*(n//loo)
else:
    ans+=(t[-1]-t[a])*(n//loo)
    ans+=t[a+n%loo]-t[a]
print(ans)
### BUGGY CODE ###

import sys
from copy import deepcopy
sys.setrecursionlimit(10 ** 9)

n = int(input())
lista = [[] for i in range(n + 1)]
ans = float('inf')
for i in range(n):
    a = int(input())
    lista[i + 1].append(a)
def dfs(now, ignore):
    global ans
    if now == 2:
        ans = min(ans, len(ignore) - 1)
    for i in lista[now]:
        if i in ignore:
            continue
        nignore = deepcopy(ignore)
        nignore.append(i)
        dfs(i, nignore)
dfs(1, [1])
print(-1 if ans == float('inf') else ans)

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getArray(N)
for i in range(N):
    A[i] -= 1
ignore = [0] * N
ignore[0] = 1

now = 0
cnt = 0
while True:
    now = A[now]
    cnt += 1
    if ignore[now] == 1:
        print(-1)
        break
    ignore[now] = 1
    if now == 1:
        print(cnt)
        break
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
sumlist = np.sort(np.array([sum(A[j:j+N-i]) for i in range(N) for j in range(i+1)]))[::-1]
ans = sumlist[0]
for i in range(40, -1, -1):
    tmp = (ans & (2 ** i)) // (2 ** i)
    if tmp:
        start = i
        break
f = lambda x: (x & onehot) // onehot
ans_list = [0]
ans = 0
for i in range(start, -1, -1):
    onehot = 2 ** i + ans
    tmp = list(map(f, sumlist))
    if sum(tmp) >= K:
        and_result = np.array(tmp).astype(np.bool)
        sumlist = sumlist[and_result]
        ans = onehot
print(ans)


### FIXED CODE ###

from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
cusum = [A[0]]
for i in range(1, N):
    cusum += [cusum[-1]+A[i]]
B = []
for i in range(N):
    B += [cusum[i]]
    for j in range(i+1, N):
        B += [cusum[j] - cusum[i]]
max_bit = 43
ans = 0
while max_bit > 0:
    counter = Counter()
    for b in B:
        for i in range(44):
            if b & 1 == 1:
                counter[i] += 1
            b = b >> 1
    for i in range(max_bit, -1, -1):
        if counter[i] >= K:
            filter_bit = 2 ** i
            B = [b for b in B if b & filter_bit == filter_bit]
            max_bit = i-1
            ans += filter_bit
            break
        max_bit = i
print(ans)
### BUGGY CODE ###

def main():
    N = int(input())
    a = list(map(int, input().split()))
    # 互いにできるだけ点数を高くしたい
    # 単に先頭と末尾を比較して大きい方を選択した場合には、選択した要素の次の要素のほうが大きい場合がある
    # dp[i][j]で左からi番目からj-1番目までだけ残っている場合にそこからとり得る最大値を考える
    # dp[0][0]

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

    for i in range(N):
        dp[i][i+1] = [a[i], 0]

    for i in range(N-1, -1, -1):
        for j in range(i+1, N+1):
            if i < N-1 and (dp[i][j][0] == 0 or (dp[i][j][0] - dp[i][j][1] < dp[i+1][j][1] + a[i] - dp[i+1][j][0])):
                dp[i][j][0] = dp[i+1][j][1] + a[i]
                dp[i][j][1] = dp[i+1][j][0]
            if j > 0 and (dp[i][j][0] == 0 or (dp[i][j][0] - dp[i][j][1] < dp[i][j-1][1] + a[j-1] - dp[i][j-1][0])):
                dp[i][j][0] = dp[i][j-1][1] + a[j-1]
                dp[i][j][1] = dp[i][j-1][0]
    # print(dp)
    print(dp[0][N][0] - dp[0][N][1])


main()


### FIXED CODE ###

def main():
    N = int(input())
    a = list(map(int, input().split()))
    # 互いにできるだけ点数を高くしたい
    # 単に先頭と末尾を比較して大きい方を選択した場合には、選択した要素の次の要素のほうが大きい場合がある
    # dp[i][j]で左からi番目からj-1番目までだけ残っている場合にそこからとり得る最大値を考える
    # dp[0][0]

    dp = [[0 for i in range(N)] for j in range(N)]

    for i in range(N):
        dp[i][i] = a[i]

    for i in range(N-1, -1, -1):
        for j in range(i+1, N):
            right = a[i] - dp[i+1][j]
            left = a[j] - dp[i][j-1]
            if right > left:
                dp[i][j] = right
            else:
                dp[i][j] = left
    # print(dp)
    print(dp[0][N-1])


main()
### BUGGY CODE ###

import math
import numpy as np
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

cut = [1] *n
r = []
for i in a:
    r.append(i)

for i in range(k):
    max_n = 0
    max_i = -1
    for i in range(n):
        if max_n < r[i]:
            max_n = r[i]
            max_i = i
    cut[max_i] += 1
    r[max_i] = a[max_i] / cut[max_i]

print(math.ceil(max(r)))

### FIXED CODE ###

import math

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

a.sort()
r = a[n-1]
l = 0


def calc(t,x):
    return math.ceil(t / x) - 1


while r - l > 1:
    mid = (r+l)//2
    count = 0
    for i in a:
        count += calc(i,mid)
    if count > k:
        l = mid
    else:
        r = mid

print(r)