Buggy python submission (verdict: Runtime Error):
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(N+1):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2

    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1

if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)

Fixed submission:
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
dis2=100
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(N+1):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2

    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1

if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)

Buggy python submission (verdict: Runtime Error):
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(101-X):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2
    #print(num,dis2,num3)
    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1
#print(numa,numb,dis,dis2)
if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)

Fixed submission:
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
dis2=100
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(N+1):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2

    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1

if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)

Buggy python submission (verdict: Runtime Error):
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])

if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(101-X):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(X+3):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2
    #print(num,dis2,num3)
    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1
#print(numa,numb,dis,dis2)
if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)

Fixed submission:
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
dis2=100
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(N+1):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2

    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1

if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)