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

for i in N
cost = min(abs(Step[n-1-i] - Step[n-2-i]),abs(Step[n-1-i] - Step[n-3-i]))
print(cost)

  

### FIXED CODE ###

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

def chmin(a, b):
  if a > b:
    return b
  else:
    return a

f_inf = float('inf')
dp = [f_inf] * (10**5 + 10)
dp[0] = 0

for i in range(1,N):
  dp[i] = chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
  if i >1:
    dp[i] = chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])
n = int(input())
l = [0]*n
s = set()
f_max,s_max = 0,0
for i in range(n):
    a = int(input())
    l[i] = a
    
    if a not in s:
        s.add(a)

    if f_max < a:
        s_max = f_max
        f_max = a
    elif s_max < a < f_max:
        s_max = a

#s.sort()

if len(s)==1:
    for i in range(n):
        print(s[0])

    exit()

for i in range(n):
    #if l[i]==f_max:
    #    print(s_max)
    #else:
    #    print(f_max)
    #if l[i]==s[-1]:
    #    print(s[-2])
    #else:
    #    print(s[-1])
    s.remove(l[i])
    print(max(s))
    s.add(l[i])



### FIXED CODE ###


n = int(input())
l = [0]*n
s = set()
f_max,s_max = 0,0
c = 0
for i in range(n):
    a = int(input())
    l[i] = a
    if f_max < a:
        s_max = f_max
        f_max = a
        c = 0
    elif s_max < a < f_max:
        s_max = a
    elif f_max == a:
        c+=1

#s.sort()

if len(s)==1:
    for i in range(n):
        print(l[0])

    exit()

if c==0:
    for i in range(n):
        if l[i]==f_max:
            print(s_max)
        else:
            print(f_max)
else:
    for i in range(n):
        print(f_max)
from fractions import gcd

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

n=int(input())
a=list(map(int, input().split()))
A=lcm(a)
ans=0

for i in a:
    ans+=A/i

print(int(ans)%(10**9+7))


### FIXED CODE ###

from fractions import gcd

n=int(input())
a=list(map(int, input().split()))
mod=10**9+7
l=1
ans=0

for i in a:
    l=l*i//gcd(l,i)

for i in a:
    ans+=l//i

print(ans%mod)
import itertools

N = int(input())
K = int(input())
p = list(map(int, input().split()))
lists = []
for l in itertools.combinations(p, K):
  sums = sum(list(l))
  lists.append(sums)

print(min(lists))
  
  


### FIXED CODE ###

S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = []
for l in range(K):
  lists.append(min(p))
  p.remove(min(p))
  
print(sum(lists))
H,N = map(int,input().split())
A = input().split()
if H - (int(sorted(A)[-1]) + int(sorted(A)[-2])) <= 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

h,a = input().split()
result = int(h)
times=0
while result > 0:
    result-=int(a)
    times+=1
print(times)
N = int(input())
n = int((N**(1/2))//1)
s =[0]*n
for i in range(1,n+1):
  if N//i == 0:
    s[i] = i
maxs = s[0]
for j in range(1,n+1):
  if s[j] > maxs:
    maxs = s[j]
p = int(N/maxs)
walk = p + maxs - 2
print(walk)


### FIXED CODE ###

N = int(input())
n = int((N**(1/2))//1)
s =[0]*(n+10)
for i in range(1,n+1):
  if N%i == 0:
    s[i] = i
maxs = s[0]
for j in range(1,n+1):
  if s[j] > maxs:
    maxs = s[j]
p = int(N/maxs)
walk = p + maxs - 2
print(walk)
# -*- coding: utf-8 -*-
N, X, M = map(int, input().split())

mod_check_list = [False for _ in range(M)]
mod_list = [(X ** 2) % M]
counter = 1
mod_sum = (X ** 2) % M
last_mod = 0
for i in range(M):
    now_mod = (mod_list[-1] ** 2) % M
    if mod_check_list[now_mod]:
        last_mod = now_mod
        break
    mod_check_list[now_mod] = True
    mod_list.append(now_mod)
    counter += 1
    mod_sum += now_mod

loop_start_idx = 0
for i in range(counter):
    if last_mod == mod_list[i]:
        loop_start_idx = i
        break

loop_list = mod_list[loop_start_idx:]
loop_num = counter - loop_start_idx
ans = 0
if mod_list[-1] == 0:
    ans = X + sum(mod_list[:min(counter, N - 1)])
else:
    if (N - 1) <= counter:
        ans = X + sum(mod_list[:counter])
        print(aa)
    else:
        ans += X + mod_sum
        N -= (counter + 1)
        ans += sum(loop_list) * (N // loop_num) + sum(loop_list[:N % loop_num])
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
N, X, M = map(int, input().split())

mod_check_list = [False for _ in range(M)]
mod_list = [(X ** 2) % M]
counter = 1
mod_sum = (X ** 2) % M
last_mod = 0
for i in range(M):
    now_mod = (mod_list[-1] ** 2) % M
    if mod_check_list[now_mod]:
        last_mod = now_mod
        break
    mod_check_list[now_mod] = True
    mod_list.append(now_mod)
    counter += 1
    mod_sum += now_mod

loop_start_idx = 0
for i in range(counter):
    if last_mod == mod_list[i]:
        loop_start_idx = i
        break

loop_list = mod_list[loop_start_idx:]
loop_num = counter - loop_start_idx
ans = 0
if mod_list[-1] == 0:
    ans = X + sum(mod_list[:min(counter, N - 1)])
else:
    if (N - 1) <= counter:
        ans = X + sum(mod_list[:N - 1])
    else:
        ans += X + mod_sum
        N -= (counter + 1)
        ans += sum(loop_list) * (N // loop_num) + sum(loop_list[:N % loop_num])
print(ans)
def getCalc(AAA, BBB):
    sum = 0
    for i in range(len(AAA)):
        sum += AAA[i] * BBB[i]
    return sum


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = list(map(int, input().split()))
    B.append(b)
    C.append(c)

AAA = []
BBB = []

for i in range(10 ** 5 + 1):
    count = A.count(i)
    if (count > 0):
        AAA.append(i)
        BBB.append(count)

for i in range(Q):
    if (B[i] in AAA):
        index = AAA.index(B[i])

        if(C[i] in AAA):
            Cindex = AAA.index(C[i])
            AAA[index] = C[i]
            BBB[index] += BBB[Cindex]
            AAA.pop(Cindex)
            BBB.pop(Cindex)
        else:
            AAA[index] = C[i]

        total = getCalc(AAA, BBB)

    print(total)


### FIXED CODE ###


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = list(map(int, input().split()))
    B.append(b)
    C.append(c)

max_num = max(max(A), max(B), max(C))

NUM = [0] * (max_num + 1)

num_list = []

for a in A:
    NUM[a] += 1

total = sum(A)

for i in range(Q):

    total += (C[i] - B[i]) * NUM[B[i]]
    NUM[B[i]], NUM[C[i]] = 0, NUM[B[i]] + NUM[C[i]]

    print(total)
from bisect import bisect_left
n = input()
lst = []
lst.append(1)
for i in range(2, int(math.sqrt(1000)) + 1):
    for j in range(2, 10):
        if i ** j <= 1000 and i ** j not in lst:
            lst.append(i ** j)

lst.sort()
print(lst[bisect_left(lst, n) - 1] if n not in lst else lst[bisect_left(lst, n)])

### FIXED CODE ###

from bisect import bisect_left
import math
n = int(input())
lst = []
lst.append(1)
for i in range(2, int(math.sqrt(1000)) + 1):
    for j in range(2, 10):
        if i ** j <= 1000 and i ** j not in lst:
            lst.append(i ** j)

lst.sort()
print(lst[bisect_left(lst, n) - 1] if n not in lst else lst[bisect_left(lst, n)])
N = int(input())
A = int(input())

if N%500=<A:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

N = int(input())
A = int(input())

if N%500<=A:
  print('Yes')
else:
  print('No')
#!/usr/bin/env python3
n, k, *a = map(int, open(0).read().split())
F = [0 for _ in range(n)]  # 来た？
T = [None for _ in range(n)]  # いつ来た？
def main(now, time, K):
    time += 1
    if F[now-1]:
        P = T[now-1]
        print(T.index(P + (K - time + 1) % (time - P)) + 1)
        exit()
    F[now-1] = 1
    T[now-1] = time
    main(a[now-1], time, K)

main(1, 0, k)

### FIXED CODE ###

n, k, *a = map(int, open(0).read().split())
a = [0] + a
p = 1
while k:
    if k % 2:
        p = a[p]
    a = [a[b] for b in a]
    k //= 2
print(p)
N, L = list(map(int, input().split()))

for i in range(1:N+1):
    apple_pie += L + i - 1

for k in range(1:N+1):
    ab = []
    ab += abs(L + k - 1)
    if min(ab):
        print(apple_pie - (L + k - 1))

### FIXED CODE ###

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

apple_pie = 0
for i in range(1, N+1):
    apple_pie += L + i - 1

ab = []
for k in range(1, N+1):
    ab.append(abs(L + k - 1))

print(apple_pie - (L + ab.index(min(ab))  ))
L, R = map(int, input().split())

if R - L >= 2050:
    print(0)
else:
    ans = 20000000
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i * j) % 2019)
    print(ans)


### FIXED CODE ###

N, A, B = map(int, input().split())
print(min(N*A, B))
print(" ".join(map(lambda x: str(x[1]), sorted([(int(a), num) for a, num in zip(input().split(" "), list(range(1,int(input()) + 1)))]))))

### FIXED CODE ###

n = int(input())
a = [(int(a), num) for a, num in zip(input().split(" "), list(range(1,n + 1)))]
a.sort()
m = len(a)
for i in range(m):
    print(a[i][1],end="")
    if(i + 1 < m):
        print(" ",end="")
print()
import math
import sympy

def main():
    a,b,c = map(int,input().split())
    left = 4*a*b
    right = (c-a-b)**2
    if (c-a-b)<0:
        return 'No'

    if left < right:
        return 'Yes'
    else:
        return 'No'

print(main())


### FIXED CODE ###

import math

def main():
    a,b,c = map(int,input().split())
    left = 4*a*b
    right = (c-a-b)**2
    if (c-a-b)<0:
        return 'No'

    if left < right:
        return 'Yes'
    else:
        return 'No'

print(main())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if b-a > k:
  print(':(')
  exit()
elif c-a > k:
  print(':(')
  exit()
elif d-a > k:
  print(':(')
  exit()
elif e-a > k:
  print(':(')
  exit()
else
  print('Yay!')
  exit()

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if b-a > k:
  print(':(')
  exit()
elif c-a > k:
  print(':(')
  exit()
elif d-a > k:
  print(':(')
  exit()
elif e-a > k:
  print(':(')
  exit()
else:
  print('Yay!')
a,b=input()
ab = int(a+b)
print("Yes" if type(ab**(1/2))==int else "No")

### FIXED CODE ###

a, b = input().split()
ab = int(a+b)

print("Yes" if ab**(1/2)%1==0 else "No")
from itertools import permutations
n, m = map(int, input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    ab[a].append(b)
    ab[b].append(a)
cnt = 0
if n == 2:
    if 1 in ab[0]:
        print(1)
    else:
        print(0)
    exit()
for p in permutations(range(1, n)):
    if p[0] in ab[0]:
        flag = True
        for i in range(n - 2):
            if p[i + 1] not in ab[p[i]]:
                flag = False
                break
        if flag:
            cnt += 1
print(cnt)

### FIXED CODE ###

a, b = map(int, input().split())
if a == b:
    print('Draw')
elif (a > b and not b == 1) or a == 1:
    print('Alice')
else:
    print('Bob')
import math 


x1, y1, x2, y2 = map(float, raw_input().split())

print sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))

### FIXED CODE ###

from math import sqrt, pow

x1, y1, x2, y2 = map(float, raw_input().split())

print sqrt(pow((x2-x1), 2)+pow((y2-y1), 2))
N,W = map(int, input().split())
dp = [0]*(W+1)

for i in range(1,N+1):
    v,w = map(int,input().split())
    for j in range(w-1,, W, -1):
    	print(j)
        x = v+dp[j-w]
        if x > dp[j]: dp[j] = x

print(dp[W])



### FIXED CODE ###

N , W = map(int,input().split())
dp = [0]*(W+1)

for i in range(N):
    n , m = map(int,input().split())
    for j in range(W,m-1,-1):
        x = n + dp[j-m]
        if x >= dp[j]:
            dp[j] = x
            
print(dp[W])
nums = input().split()
a = int(nums[0])
b = nums[1]

res = ""
for ch in b:
	if ch not in ('0', '.'):
		res += ch
		
b = int(res)

prod = (a * b) // 100

print(prod)


### FIXED CODE ###

nums = input().split()
a = int(nums[0])
b = nums[1]

res = ""
for ch in range(len(b)):
	if b[ch] != '.':
		res += b[ch]
		
b = int(res)

prod = (a * b) // 100

print(prod)
N = int(input())
s = []
for i in range(N):
    s.append(sorted(list(input())))

ans = 0
for i in range(N):
    for j in range(N):
        if not i == j:
            if (si == sj):
                ans += 1
print(int(ans/2))

### FIXED CODE ###

N = int(input())
s = []
ans = 0
mydict = {}
for i in range(N):
    s = "".join(sorted(list(input())))
    if (s in mydict.keys()):
        ans += mydict[s]
        mydict[s] += 1
    else:
        mydict[s] = 1
print(ans)
n,m=map(int,input().split())
c=sum([list(map(int,input().split())) for i in range(m)],[])
from collections import Counter as co
for i in co(c).values():
    if i%2:print("NO");exit()
  print("YES")

### FIXED CODE ###

n,m=map(int,input().split())
l=[0]*(n+1)
for i in range(m):
    a,s=map(int,input().split())
    l[a]+=1
    l[s]+=1
for i in l:
    if i%2:print("NO");exit()
print("YES")
import collections
q = collections.deque(maxlen=100000)

n = int(input())
for i in range(n):
    com = input().split()
    if com[0]=='insert':
        q.appendleft(int(com[1]))
    elif com[0]=='delete':
        try:
            q.remove(int(com[0]))
        except ValueError:
            pass
    elif com[0]=='deleteFirst':
        q.popleft()
    elif com[0]=='deleteLast':
        q.pop()
print(' '.join(q))

### FIXED CODE ###

import collections
n,q = map(int, input().split())
queue = collections.deque(maxlen=100000)

for i in range(n):
    p,t = input().split()
    queue.append([p, int(t)])

time = 0
while queue:
    p,t = queue.popleft()
    if t<=q:
        time += t
        print(p,time)
    else:
        time += q
        queue.append([p,t-q])
C1 = str(input())
C2 = str(input())

if C1[0] == C2[1] and C1[1] == C2[2] and C1[2] == C2[3]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

C1 = str(input())
C2 = str(input())

if C1[0] == C2[-1] and C1[1] == C2[-2] and C1[2] == C2[-3]:
    print('YES')
else:
    print('NO')
N=int(input())
S=input()
len_of_s=len(S)
if len_of_s%2==0 and S[:len_of_s/2+1]==s[len_of_s/2+1:]:
  print("Yes")
elif
  print("No")

### FIXED CODE ###

N=int(input())
S=input()
len_of_s=len(S)
if len_of_s%2==0 and S[:len_of_s//2]==S[len_of_s//2:]:
  print("Yes")
else:
  print("No")
import sys
input=lambda: sys.stdin.readline().rstrip()

n,m=map(int,input().split())
A=[int(i)//2 for i in input().split()]
ct=0
s=A[0]
while s:
  if s%2==0:
    s//=2
    ct+=1
  else:
    s=0
chk=True
for i in range(1,n):
  cur=0
  a=A[i]
  while a:
  if a%2==0:
    a//=2
    cur+=1
  else:
    a=0
  if cur!=ct:
    chk=False
    break


def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
if not chk:
  print(0)
else:
  lcm=A[0]
  for i in range(1,n):
    lcm*=A[i]//gcd(lcm,A[i])
  print((m//lcm+1)//2)

### FIXED CODE ###

n,m=map(int,input().split())
A=[int(i)//2 for i in input().split()]

def gcd(a,b):
  while b:
    a,b=b,a%b
  return a

def div2(x):
  ret=0
  while x%2==0:
    ret+=1
    x//=2
  return ret

s=div2(A[0])
chk=True

mul=A[0]
for i in range(1,n):
  if s!=div2(A[i]) or mul>m:
    chk=False
  else:
    mul=mul*A[i]//gcd(mul,A[i])
if not chk:
  print(0)
else:
  print(m//mul-m//(mul*2))
n=int(input())
print(100*(10-n[0])+10*(10-n[1])+10-n[2])

### FIXED CODE ###

n = input()
n = n.replace("9","4").replace("1","9").replace("4","1")
print(n)
from sys import stdin
import numpy as np

k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            ans+=np.gcd(i,np.gcd(j,k))
print(str(ans)+"\n")


### FIXED CODE ###

from sys import stdin

A=input()
if A[0]=='7' or A[1]=='7' or A[2]=='7':
    print("Yes\n")
else:
    print("No\n")
import re
print(max(map(len,re.finditer('[ACGT]*',input()))))

### FIXED CODE ###

p = 'ACGT'
s = input()
l = len(s)
r = 0
i = -1
while i < l:
 i = next((i for i in range(i + 1, l) if s[i] in p), l)
 j = next((i for i in range(i + 1, l) if s[i] not in p), l)
 r = max(r, j - i)
 i = j
print(r)
S = input()
T = input()
     
T.pop(-1)
     
if S == T:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

S = input()
T = input()
     
if S == T[:-1]:
  print('Yes')
else:
  print('No')
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import numpy as np

N = int(readline())
LR = [tuple(int(x) for x in line.split()) for line in readlines()]

"""
・奇数個のとき：中央にどれかを固定。
・偶数のとき：原点で左右に分けるとしてよい。
・基本的に長さで内側から昇順（奇数のときの中央は謎）。→ソートしてdpできる。
・左に置いた個数をもってdp更新。また、中央を使ったかも同時に持って。
・偶数のときは、中央に1つ置いた状態から始める。
・大きい区間から外側に入れていく。
"""

LR.sort(key = lambda x: -x[1]-x[0])

if N%2 == 1:
    raise Exception



INF = 10**18
dp_0 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央未確定。
dp_1 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央確定。
if N&1:
    dp_0[0] = 0
else:
    dp_1[0] = 0
for n,(L,R) in enumerate(LR):
    length = R + L
    prev_0 = dp_0
    prev_1 = dp_1
    dp_0 = np.full(N+1,INF,np.int64)
    dp_1 = np.full(N+1,INF,np.int64)
    x = np.arange(n+1,dtype=np.int64) # もともと左側にあった個数
    # 左側に置く場合
    np.minimum(prev_0[:n+1] + R + x * length, dp_0[1:n+2], out=dp_0[1:n+2])
    np.minimum(prev_1[:n+1] + R + x * length, dp_1[1:n+2], out=dp_1[1:n+2])
    # 右側に置く場合
    np.minimum(prev_0[:n+1] + L + (n-x) * length, dp_0[:n+1], out=dp_0[:n+1])
    np.minimum(prev_1[:n+1] + L + (n-x) * length, dp_1[:n+1], out=dp_1[:n+1])
    # 中央に置く場合
    np.minimum(prev_0[:n+1] + (N-1)//2 * length, dp_1[:n+1], out = dp_1[:n+1])

answer = dp_1[N//2]
print(answer)

### FIXED CODE ###

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import numpy as np

N = int(readline())
LR = [tuple(int(x) for x in line.split()) for line in readlines()]

"""
・奇数個のとき：中央にどれかを固定。
・偶数のとき：原点で左右に分けるとしてよい。
・基本的に長さで内側から昇順（奇数のときの中央は謎）。→ソートしてdpできる。
・左に置いた個数をもってdp更新。また、中央を使ったかも同時に持って。
・偶数のときは、中央に1つ置いた状態から始める。
・大きい区間から外側に入れていく。
"""

LR.sort(key = lambda x: -x[1]-x[0])

INF = 10**18
dp_0 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央未確定。
dp_1 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央確定。
if N&1:
    dp_0[0] = 0
else:
    dp_1[0] = 0
for n,(L,R) in enumerate(LR):
    length = R + L
    prev_0 = dp_0
    prev_1 = dp_1
    dp_0 = np.full(N+1,INF,np.int64)
    dp_1 = np.full(N+1,INF,np.int64)
    x = np.arange(n+1,dtype=np.int64) # もともと左側にあった個数
    # 左側に置く場合
    np.minimum(prev_0[:n+1] + R + x * length, dp_0[1:n+2], out=dp_0[1:n+2])
    np.minimum(prev_1[:n+1] + R + x * length, dp_1[1:n+2], out=dp_1[1:n+2])
    # 右側に置く場合
    np.minimum(prev_0[:n+1] + L + (n-x) * length, dp_0[:n+1], out=dp_0[:n+1])
    np.minimum(prev_1[:n+1] + L + (n-x) * length, dp_1[:n+1], out=dp_1[:n+1])
    # 中央に置く場合
    np.minimum(prev_0[:n+1] + (N-1)//2 * length, dp_1[:n+1], out = dp_1[:n+1])

answer = dp_1[N//2]
print(answer)
N,M = map(int,input().split())
#N>=Mとして一般性を失わない
if N==M==1:
    print(1)
if N==1 and M>=2:
    print(M-2)
if N==2 and M>=2:
    print(0)
if N>=3 and M>=3:
    print((N-2)*(M-2)

### FIXED CODE ###

l = sorted(list(map(int,input().split())))
#N<=Mとして一般性を失わない
N=l[0]
M=l[1]

if N==M==1:
    print(1)
if N==1 and M>=2:
    print(M-2)
if N==2 and M>=2:
    print(0)
if N>=3 and M>=3:
    print((N-2)*(M-2))
N = int(input())
a = []
for i in range(N):
    a.append(map(int, input())

for i in range(N):
    v = a[i]
    j = i-1
    while j>=0 and a[j]>v:
        a[j+1] = a[j]
        j = j-1
        a[j+1] = v
    print(a)


### FIXED CODE ###

N = int(input())
a = input().split()
b = [int(n) for n in a]


for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    print(" ".join([str(n) for n in b]))
import numpy as np
listA=[]
lis=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
#print(listA)

X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]

    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)   

    for i in range(P_max+1):
        lis.append(i)
    lis.remove(0)
    
    arr=arr[arr<=P_max]
    arr=arr[arr>=P_min]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    #print(lis)
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    #print(lis_)
    lis_min=min(lis_)

    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default

    print(lis[my_index(lis_, lis_min)])
else:
    print(X)

### FIXED CODE ###

import numpy as np
lis=[]
for i in range(102):
    lis.append(i)
#print(lis)
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
#print(listA)
 
X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]
 
    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)-1
    arr=arr[arr<=P_max+1]
    arr=arr[arr>=P_min-1]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    #print(lis)
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    #print(lis_)
    lis_min=min(lis_)
 
    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default
 
    print(lis[my_index(lis_, lis_min)])
else:
    print(X)
# -*- coding: UTF-8 -*-
L, N = map(int, input().split())
a = list(input() for i in range(N))
a.sort()
b = " ".join(a)
print(b)

### FIXED CODE ###

# -*- coding: UTF-8 -*-
N, L = map(int, input().split())
a = [input() for i in range(N)]
a.sort()
b = "".join(a)
print(b)
import math

A, B, H, M=map(int,input().split(" "))

a = int(A)
b = int(B)
h = int(H)
m = int(M)
ang = 6*m - (30*h + 0.5*m)

if ang > 0:
	ang = ang
else:
	ang = 360 - ang

cosa =math.cos(ang)

c = math.sqrt(a^2 + b^2 - 2 * a * b * cosa)


print(c)


### FIXED CODE ###

import math

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

ha = (M / 60 + H)*30
ma = M*6
ang = ha - ma

cosa =math.cos(ang*math.pi/180)

c = math.sqrt(A**2 + B**2 - 2 * A * B * cosa)


print(c)
import math
a,b = map(int, input().split())
print(math.cail((a+B)/2))

### FIXED CODE ###

import math

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

x = math.ceil((a+b)/2)

print(x)
x,y,z = input().split
print(z,x,y)



### FIXED CODE ###

x,y,z = input().split(" ")
print(z,x,y)
k,a,b = map(int,input().split())
if a+2>=b:
  print(1+k)
else:
  #bisできるセット
  q = (k-a+1)//2
  if q ==0:
    print(i+k)
  else:
    print(1+(k-2*q)+q*(b-a))

### FIXED CODE ###

k,a,b = map(int,input().split())
if a+2>=b:
  print(1+k)
else:
  #bisできるセット
  q = (k-a+1)//2
  if q ==0:
    print(1+k)
  else:
    print(1+(k-2*q)+q*(b-a))
a ,b= map(int,input().split())
aaa = [list(map(int,input().split())) for i in range(b*2)]

s = {i for i in range(1,a+1)}

for i in range(1,a+1,2):
    for k in aaa[i]:
        s.discard(k)

print(len(s))

### FIXED CODE ###

a,b = map(int,input().split())
aaa = [list(map(int,input().split())) for i in range(b*2)]

c = set()
e = set()
for i in range(1,len(aaa),2):
  for k in aaa[i]:
     c.add(k)
    
print(a - len(c))
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
#print(A)

b = [0.5 for _ in range(N)]
B0 = np.diag(b)
b.pop()
B1 = np.diag(b, k=1)
B = B0 + B1
B[N-1][0] = 0.5
#print(B)

#x = np.linalg.solve(B, A)
Binv = np.linalg.inv(B)
x = np.dot(Binv, A)
x = map(int, x)
ans = ' '.join(map(str, x))
print(ans)

### FIXED CODE ###

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

x = 0
for i in range(N): # x_0の値を得る
    if i % 2 == 0:
        x += A[i]
    else:
        x -= A[i]

for i in range(N):
    print(x, end=' ') # x_iをprint
    x = 2 * A[i] - x # x_(i+1)を得る