Harryxun/stf_run huggingface dataset:
n = int(input())
A = list(map(int,input().split()))

counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1 or A[i]==0:
      end_judge = 1
    else:
      A[i] = A[i] / 2    
  if end_judge == 1:
    break    
  counter += 1
  
print(counter)

### FIXED CODE ###

li = list(input())
count = 0
for i in range(3):
  if li[i] == '1':
    count += 1
print(count)
n = input()
s = list(map(int, input.split()))
ans = 0

while all(a%2==0 for a in s):
  ans +=1
  for a in s:
    s = a/2

print(ans)


### FIXED CODE ###

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

while all(a%2==0 for a in s):
  ans +=1
  s = [a/2 for a in s]

print(ans)
A,B,C= input().split()

if (A==B) and (B==C):
    print(‘Yes’)
else:
    print(‘No’)

### FIXED CODE ###

A,B,C= input().split()

if (A==B) and (B==C):
  print('Yes')
else:
  print('No')
n=int(input())
v=[int(i) for i in range(n)]
c=[int(i) for i in range(n)]
ans=[]
for i in range(2**n):
	for j in range(n):
		if (i>>j)&1:
			sum_v+=v[j]
			sum_c+=c[j]
			ans.append(sum_c-sum_v)
print(max(ans))

### FIXED CODE ###

n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
sum_v=0
sum_c=0
for i in range(n):
	if v[i]-c[i]>=0:
		sum_v+=v[i]
		sum_c+=c[i]
		ans.append(sum_v-sum_c)
try:
	print(max(ans))
except ValueError:
	print("0")
# coding: utf-8

# In[17]:

import sys
#input = sys.stdin.readline
N = int(input())


# In[3]:

import numpy as np


# In[ ]:

sum_ = 0
a = np.arange(1, N)
#print(a)
print(np.sum(a[N//a==N%a]))
#print(a)
#for m in range(1, (N-2)//2):
#    if (N-m)%m==0:
#        print(m)
#        sum_ += (N-m)/m
#print(sum_)


# In[ ]:





### FIXED CODE ###


# coding: utf-8

# In[10]:

import sys
#import math
#input = sys.stdin.readline
N = int(input())


# In[13]:

sum_ = 0
#print(math.sqrt(N))
#print(int(math.sqrt(N)))
#print(int(N**0.5))
rn = N**0.5
if rn%1 == 0:
    rn -= 1
for i in range(1, int(rn)+1):
    if N%i == 0 and i < N//i-1:
        #print(i)
        #print(N/i-1)
        sum_ += N/i-1
print(int(sum_))


# In[ ]:
N, Y = map(int, input().split())

m1 = Y // 10000
m2 = Y % 10000
if m1 > N:
    print("-1 -1 -1")
elif m1 == N and m2 > 0:
    print("-1 -1 -1")
else:
    c =False
    for i in range(m1+1):
        if Y - 10000*i > 5000*(N-i):
            pass
        else:
            for j in range(N+1-i):
                if Y == 10000*i + 5000*j + 1000*(N-i-j):
                    a = [str(i), str(j), str(N-i-j)]
                    print(" ".join(a))
                    c = True
                    break
        if c:
            break
if not c:
    print("-1 -1 -1")


### FIXED CODE ###

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

c =False
for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j):
            a = [str(i), str(j), str(N-i-j)]
            print(" ".join(a))
            c = True
            break
    if c:
        break
if not c:
    print("-1 -1 -1")
word = input()
if word[-1] == "s":
  print(word + "es)
else:
  print(word)


### FIXED CODE ###

word = input()
if word[-1] == "s":
  print(word + "es")
else:
  print(word + "s")
import bisect
import sys
A, B, Q = map(int, input().split())
INF = 10 ** 13
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
xs = [int(sys.stdin.readline()) for i in range(Q)]
for x in range(xs):
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

### FIXED CODE ###

import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
a=input()
if int(a) < int(a[0])*111:
  print(int(a[0])*111)
else:
  print((int(a[0])+1)*111

### FIXED CODE ###

a=input()
if int(a) <= int(a[0])*111:
  print(int(a[0])*111)
else:
  print((int(a[0])+1)*111)
x, n = map(int, input(). split())
m = [0]*200
ans = 0
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  quit()
for i in range(n):
  l = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] < 2:
      a = x-j
      A = x+j
      b = p.count(a)
      if b == 0:
        ans = a
      else:
        ans = A
      break
print(ans)


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    x,n = LI()
    p = LI()
    f = [1]*(200)
    for i in p:
        f[i] = 0
    ans = x
    m = 0
    for i in range(200):
        if f[i]:
            d = abs(i-x)
            if d < ans:
                ans = d
                m = i
    print(m)
    return

#Solve
if __name__ == "__main__":
    solve()
a,b = map(int, raw_input().split());

print 2*(a+b), a*b;

### FIXED CODE ###

a, b = map(int, raw_input().split())

print a*b, 2*(a+b)
import sys
N, M = map(int, input().split())
if M & 1:
    print(-1)
    sys.exit()
Edge = [[] for _ in range(N)]
Dim = [0]*N
for _ in range(M):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)
    Dim[a] += 1
    Dim[b] += 1
Ans = []
used = set()
odd = [False]*N
for i in sorted(range(N), key = lambda x: Dim[x]):
    Edge[i].sort(key = lambda x: Dim[x], reverse = True)
    while Dim[i] > 1:
        while (i, Edge[i][-1]) in used:
            Edge[i].pop()
        j1 = Edge[i].pop()
        while (i, Edge[i][-1]) in used:
            Edge[i].pop()
        j2 = Edge[i].pop()
        Ans.append((i+1, j1+1))
        Ans.append((i+1, j2+1))
        Dim[i] -= 2
        Dim[j1] -= 1
        Dim[j2] -= 1
        used.add((i, j1))
        used.add((i, j2))
        used.add((j1, i))
        used.add((j2, i))
assert len(Ans) == M,''

for a in Ans:
    print(*a)       


### FIXED CODE ###

import sys
readline = sys.stdin.readline
write = sys.stdout.write
sys.setrecursionlimit(2*10**6)
class UF():
    def __init__(self, num):
        self.par = [-1]*num
        self.size = [1]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            x = self.par[x]
            return self.find(x)
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.par[rx] < self.par[ry]:
                self.par[ry] = rx
                self.size[rx] += self.size[ry] 
            elif self.par[rx] > self.par[ry]:
                self.par[rx] = ry
                self.size[ry] += self.size[rx]
            else:
                self.par[rx] -= 1
                self.par[ry] = rx
                self.size[rx] += self.size[ry]
            return True
        return False

def getpar(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[0] = -1
    par[p]  -1
    stack = [p]
    visited = set([p])
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            stack.append(vf)
    return par

def topological_sort_tree(E, r):
    Q = [r]
    L = []
    visited = set([r])
    while Q:
        vn = Q.pop()
        L.append(vn)
        for vf in E[vn]:
            if vf not in visited:
                visited.add(vf)
                Q.append(vf)
    return L

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

Edge = []
for _ in range(M):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge.append((a, b))

tr = [[] for _ in range(N)]
ans = []
eo = [0]*N
T = UF(N)
for a, b in Edge:
    if T.union(a, b):
        tr[a].append(b)
        tr[b].append(a)
    else:
        ans.append((a+1, b+1))
        eo[a] ^= 1

L = topological_sort_tree(tr, 0)
P = getpar(tr, 0)
for l in L[1:][::-1]:
    if eo[l]:
        ans.append((l+1, P[l]+1))
    else:
        ans.append((P[l]+1, l+1))
        eo[P[l]] ^= 1
if M % 2 == 0:
    for a, b in ans:
        write('{} {}\n'.format(a, b))
else:
    write('-1\n')
A = input()
B = input()

if B > A/2:
  print(0)
else:
  print(A-2*B)

### FIXED CODE ###

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

answer = a - 2 * b

if (answer < 0):
  print(0)
else:
  print(answer)
l = list(map(int, input().split(' ')))
if int(''.join(l)) % 4 = 0:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

x = int(''.join(input().split()))
if x % 4 == 0:
    print('YES')
else:
    print('NO')
def seek_dup(s):
    t_list = [t for (t, d) in s]
    #d_list = [d for (t, d) in s]
 
    for t, d in reversed(s):
        if t_list.count(t) > 1:
            return (t, d)
        else:
            continue
        
    return None
 
N, K = map(int, input().split())
menu_ = []
 
for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))
 
menu = sorted(menu_, key = lambda x:x[1], reverse=True)
p = sum([d for (t, d) in menu[:K]]) + len(set([t for (t, d) in menu[:K]]))**2
 
selected_menu = menu[:K]
#t_list = [t for (t, d) in selected_menu]
#d_list = [d for (t, d) in selected_menu]
ans = p
for m in menu[K:]:
    t_list = [t for (t, d) in selected_menu]
    d_list = [d for (t, d) in selected_menu]
    
    if m[0] not in t_list and len(set(t_list)) == len(t_list):
        d = seek_dup(selected_menu)
        if d == None:
            continue
        
        selected_menu.remove(d)
        selected_menu.append(m)
    
    p += (m[1] - d[1]) + 2 * len(set(t_list)) - 1 
    #print(ans, p)
    ans = max(ans, p)
 
print(ans) 

### FIXED CODE ###

N, K = map(int, input().split())
menu_ = []

for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))

menu = sorted(menu_, key = lambda x:x[1], reverse=True)
neta = set()
duplicates = []

for m in menu[:K]:
    if m[0] in neta:
        duplicates.append(m[1])
    else:
        neta.add(m[0])

p = sum([d for (t, d) in menu[:K]]) + len(neta)**2
ans = p

for m in menu[K:]:
    if m[0] not in neta and duplicates:
        neta.add(m[0])
        duplicate = duplicates.pop()
        
        p += (m[1] - duplicate) + 2 * len(neta) - 1 
        #print(ans, p)
        ans = max(ans, p)

print(ans)
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().rstrip()
N = ii()
S = ns()
print(S.counet("#."))


### FIXED CODE ###

from collections import Counter
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().rstrip()
N = ii()
S = ns()
bs = [0] * (N + 1)
ws = [0] * (N + 1)
total = float("inf")
left_b = 0
right_w = 0
for i, s in enumerate(S):
    if s == "#":
        left_b += 1
    bs[i + 1] = left_b
for i in reversed(range(N)):
    if S[i] == ".":
        right_w += 1
    ws[i] = right_w

for i in range(N):
    total = min(total, ws[i+1] + bs[i])

print(total)
n, x = [int(i) for i in input().split()]

3 <= n <= 100

if n == x == 0:
    break

for a in range(1, n+1):
    for b in range(1, a+1):
        for c in range(1, b+1):
             if a == b == c or a == b or a == c or b == c:
             None
             if a + b + c == x:
             return
             else:
             None
print()

### FIXED CODE ###

while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n+1):
        for m in range(s+1, n):
            for e in range(m+1, n+1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)
h,w,a,b = map(int,input().split())
ans = [[0]*w for i in range(h)]
fl = True

if h == 1:
    for i in range(a):
        ans[0][i] = 1
elif w == 1:
    for i in range(b):
        ans[i][0] = 1
else:
    if h % b == 0 and w % a == 0 and h // b == w // a:
        al = h // b
        for i in range(al):
            for j in range(b):
                for k in range(a):
                    ans[b*i+j][a*i+k] = 1
                    
    else:
        fl = False
        
if fl:
    for i in range(h):
        print(*ans[i],sep = "")
else:
    print("No")

### FIXED CODE ###

h,w,a,b = map(int,input().split())
ans = [[0]*w for i in range(h)]
fl = True

for i in range(a):
    for j in range(b):
        ans[j][i] = 1
        
for i in range(w-a):
    for j in range(h-b):
        ans[b+j][a+i] = 1
        
for i in range(h):
    print(*ans[i],sep = "")
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *
from random import *					# alpha = ascii_lowercase
from sys import stdin
from itertools import *
from collections import Counter			# z = dict(Counter(l))

def solve(l,n,k):
	if(n == 2):
		return abs(l[0] - l[1])
	else:
		dp = [999999999999]*n
		dp[1] = abs(l[0] - l[1])
		for i in range(1,n):
			j = K
			while(j > 0):
				if(i-j < n):
					dp[i] = min(dp[i-j] + abs(l[i] - l[i-j]), dp[i])
				j -= 1
		return dp[-1]


N,K = map(int, stdin.readline().rstrip().split())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,N,K)
print(ans)

### FIXED CODE ###

# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *
from random import *					# alpha = ascii_lowercase
from sys import stdin
from itertools import *
from collections import Counter			# z = dict(Counter(l))

def jump(l,i,end):
	dp = [0]*len(l)
	if(len(l) == 2):
		return abs(l[0] - l[1])
	dp[1] = abs(l[0] - l[1])
	for i in range(2,len(l)):
		dp[i] = min(abs(l[i] - l[i-2]) + dp[i-2], abs(l[i] - l[i-1]) + dp[i-1])
	return dp[-1]


N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = jump(l,N-1,N-1)
print(ans)
input()
data = input().split()

minimum = min(data)
maximum = max(data)
total = sum(data)

print(minimum, maximum, total)

### FIXED CODE ###

from sys import stdin

count = int(stdin.readline())
ns = [int(n) for n in stdin.readline().split(' ')]
minimum = None
maximum = None
total = 0

for n in ns:
    if minimum == None or minimum > n:
        minimum = n
    if maximum == None or maximum < n:
        maximum = n

    total += n

print(minimum, maximum, total)
a,b,c = map(int,input().split())

if 1 <= a, b, c <= 10000 and a <= b:
    l = [i for i in range(a,b+1) if c % a ==0]
print(len(l))

### FIXED CODE ###

a,b,c = map(int,input().split())
l = [i for i in range(a,b+1) if c%i == 0]
print(len(l))
import math
n, k = map(int, input().split())
mod = 10**9+7
for i in range(1, k+1):
    count = 0
    i_poss_count = math.factorial(n-k+1) \
                   // (math.factorial(n-k-i+1) * math.factorial(i))
    split_count = math.factorial(k-1) \
                  // (math.factorial(k-i) * math.factorial(i-1))
    count = i_poss_count * split_count
    print(count % mod)

### FIXED CODE ###

import math
n, k = map(int, input().split())
mod = 10**9+7
for i in range(1, k+1):
    if i > n-k+1:
        print(0)
        continue
    count = 0
    i_pos_count = math.factorial(n-k+1) \
                   // (math.factorial(n-k-i+1) * math.factorial(i))
    split_count = math.factorial(k-1) \
                  // (math.factorial(k-i) * math.factorial(i-1))
    count = i_pos_count * split_count
    print(count % mod)
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
A=list(map(int, input().split()))
L = 1
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans = ans + L/a

MOD = 1000000007
print(int(ans)%MOD)


### FIXED CODE ###

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
A=list(map(int, input().split()))
L = 1
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans = ans + L//a

MOD = 1000000007
print(int(ans)%MOD)
import sys

def isCLKWISE(ph):
    if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph

input = sys.stdin.readlines()
n = int(input[0])
P = map(lambda x: x.split(), _input[1:])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

### FIXED CODE ###

def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
P = [[int(x) for x in input().split()] for _ in range(int(input()))]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])
a = input()
n = input()
m = input()
first = a.split(" ")
N = n.split(" ")
M = m.split(" ")

overflow = 0
for i in N:
    if int(i) > 10**9:
        overflow = 1
        break
        
for i in M:
    if int(i) > 10**9:
        overflow = 1
        break


if overflow == 0:
    totaltime = 0
    count = 1
    for i in range(int(first[1]) + int(first[0])):
      if totaltime + int(N[0]) > int(first[2]) or totaltime + int(M[0]) > int(first[2]):
        break
      if int(N[0]) < int(M[0]):
        totaltime += int(N[0])
        N.remove(N[0])
        count += 1
      elif int(M[0]) < int(N[0]):
        totaltime += int(M[0])
        M.remove(M[0])
        count += 1
    print(count)
else:
    print(0)

### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
    ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[-1]+1)
    else:
        a.append(a[-1])
print(a)
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    print(a[t-1]-a[u-1])

### FIXED CODE ###

n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])
A,B=map(int,input().split())
if A>8 or b>8:
    print(":\(")
else:
    print("Yay!")

### FIXED CODE ###

A,B=map(int,input().split())
if A>8 or B>8:
    print(":(")
else:
    print("Yay!")
N = int(input())
print(N*(N-1)///2)

### FIXED CODE ###

a = int(input())
print(int(0.5*a*(a+1)))
s = list(map(int, input()))
t = [1, 4, 7, 9]
[t.pop() for i in sorted(s) if i in t]
if len(t) == 4:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

s = list(map(int, input().split()))
if sorted(s) == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")
hour = input() // 3600
minute = input() - 3600 * hour
second = hour - 60 * minute

print( hour ':' minute ':' second ':' )

### FIXED CODE ###

sec_ = int(input())
print("{}:{}:{}".format(sec_//3600, (sec_//60)%60, sec_%60))
from heapq import heappush, heappop
from collections import deque

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

ans = 0

for i in range(K+1):
    for l in range(i+1):
        for r in range(i+1-l):
            j = min(i-r-l,r+l)
            hq = []
            dq = deque(V)
            for _ in range(l):
                if dq:
                    item = dq.popleft()
                    heappush(hq, item)
            for _ in range(r):
                if dq:
                    item = dq.pop()
                    heappush(hq, item)
            for _ in range(j):
                heappop(hq)
            res = sum(hq)
            ans = max(ans,res)
        
print(ans)

### FIXED CODE ###

from heapq import heappush, heappop
from collections import deque

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

ans = 0

for i in range(K+1):
    sup = min(i,N)
    for l in range(sup+1):
        for r in range(sup+1-l):
            j = min(i-r-l,r+l)
            hq = []
            dq = deque(V)
            for _ in range(l):
                item = dq.popleft()
                heappush(hq, item)
            for _ in range(r):
                item = dq.pop()
                heappush(hq, item)
            for _ in range(j):
                heappop(hq)
            res = sum(hq)
            ans = max(ans,res)

print(ans)
import sys
input = sys.stdin.readline
from fractions import gcd

N=int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9+ 7

def cal_lcm(a, b):
  return int(a*b/gcd(a,b))


lcm = 1
sum_b = 0
ans = 0
for i in range(N):
  lcm_ = cal_lcm(lcm, a_list[i])
  ans = ans*int(lcm_/lcm) % MOD
  ans = (ans + int(lcm_/a_list[i])) % MOD
  lcm = lcm_

print(ans)

### FIXED CODE ###

from fractions import gcd
 
N=int(input())
a_list = tuple(int(i) for i in input().split())
MOD = 10**9+7

def cal_lcm(a, b):
  return int(a*b//gcd(a,b))

lcm = 1
for i in range(N):
  lcm = cal_lcm(lcm, a_list[i])
  
ans = 0
for i in range(N):
  ans += lcm//a_list[i]
print(ans%MOD)
a,b =(int(i) for i in input.split())
if a > b:
 print("a > b")
elif  a == b:
 print("a == b")
else a < b: 
 print("a < b")


### FIXED CODE ###

a,b =map(int, input().split())
if a > b:
 print("a > b")
elif  a == b:
 print("a == b")
else : 
 print("a < b")
n=input()
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
    a=l[i:i+3]
    b=a[1]
    c=sorted(a)
    if b==c[1]:
        ans+=1
print(ans)

### FIXED CODE ###

n=int(input())-1
l=list(map(int,input().split()))
l.sort()
m=n//2
if l[m]==l[m+1]:
    print(0)
else:
    print(l[m+1]-l[m])