Buggy python submission (verdict: Time Limit Exceeded):
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))

  flag=0
  i=0
  while flag==0:
    continueflag=0
    for j in a:
      if j==x-i:
        continueflag=1
        break
    if continueflag==0:
      print(x-i)
      break
      
    for j in a:
      if j==x+i:
        continueflag=1
        break
    if continueflag==0:
      print(x+i)
      break
  i=i+1
    


Fixed submission:
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))
  flag=0
  i=0
  while flag==0:
    continueflag=0
    for j in range(n):
      if a[j]==x-i:
        continueflag=1
        break
    if continueflag==0:
      print(x-i)
      break
      
    continueflag=0
    for j in range(n):
      if a[j]==x+i:
        continueflag=1
        break
    if continueflag==0:
      print(x+i)
      break
    i=i+1

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))

  dtmp=100
  for i in range(1,101):
    continueflag=0
    for j in a:
      if j==i:
        continueflag=1
        break
    if continueflag==1:
      continue
    d=abs(x-i)
    if d<dtmp:
      dtmp=d
      ans=i

  print(ans)

Fixed submission:
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))
  flag=0
  i=0
  while flag==0:
    continueflag=0
    for j in range(n):
      if a[j]==x-i:
        continueflag=1
        break
    if continueflag==0:
      print(x-i)
      break
      
    continueflag=0
    for j in range(n):
      if a[j]==x+i:
        continueflag=1
        break
    if continueflag==0:
      print(x+i)
      break
    i=i+1

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))

  dtmp=100
  for i in range(1,100):
    continueflag=0
    for j in a:
      if j==i:
        continueflag=1
        break
    if continueflag==1:
      continue
    d=abs(x-i)
    if d<dtmp:
      dtmp=d
      ans=i

  print(ans)
    

Fixed submission:
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))
  flag=0
  i=0
  while flag==0:
    continueflag=0
    for j in range(n):
      if a[j]==x-i:
        continueflag=1
        break
    if continueflag==0:
      print(x-i)
      break
      
    continueflag=0
    for j in range(n):
      if a[j]==x+i:
        continueflag=1
        break
    if continueflag==0:
      print(x+i)
      break
    i=i+1

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
a=list(map(int,input().split()))

dtmp = 100
for i in range(n):
  d=abs(x-a[i])
  if d<dtmp:
    dtmp=d
    ans=x
  elif d==dtmp:
    ans=x
print(ans)

Fixed submission:
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))
  flag=0
  i=0
  while flag==0:
    continueflag=0
    for j in range(n):
      if a[j]==x-i:
        continueflag=1
        break
    if continueflag==0:
      print(x-i)
      break
      
    continueflag=0
    for j in range(n):
      if a[j]==x+i:
        continueflag=1
        break
    if continueflag==0:
      print(x+i)
      break
    i=i+1