Buggy python submission (verdict: Runtime Error):
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

# p.sort()

# minimum = p[0]
# maximum = p[len(p) - 1]

# if X < minimum or maximum < X:
#     print(X)
#     exit()

# diff_min = abs(X - minimum - 1)
# diff_max = abs(X - maximum + 1)
# if diff_min == diff_max:
#     answer = min(minimum - 1, maximum + 1)
# else:
#     answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)


Fixed submission:
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]

if X < minimum or maximum < X:
    print(X)
    exit()

diff_min = abs(X - minimum - 1)
diff_max = abs(X - maximum + 1)
if diff_min == diff_max:
    answer = min(minimum - 1, maximum + 1)
else:
    answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)

Buggy python submission (verdict: Runtime Error):
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

if X < minimum or maximum < X:
    print(X)
    exit()

answer = 1
for candidate in range(1, 100 + 1):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)


Fixed submission:
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]

if X < minimum or maximum < X:
    print(X)
    exit()

diff_min = abs(X - minimum - 1)
diff_max = abs(X - maximum + 1)
if diff_min == diff_max:
    answer = min(minimum - 1, maximum + 1)
else:
    answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)

Buggy python submission (verdict: Runtime Error):
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]
# print(minimum, maximum)

if X < minimum or maximum < X:
    print(0)
    exit()

# answer = min(abs(X - minimum - 1), abs(X - maximum + 1))
for candidate in range(minimum, maximum):
    if candidate in p: continue

    diff_answer = abs(X - answer)
    diff_candidate = abs(X - candidate)
    # print(candidate, diff, answer)
    answer = candidate if diff_candidate < diff_answer else answer

print(answer)


Fixed submission:
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]

if X < minimum or maximum < X:
    print(X)
    exit()

diff_min = abs(X - minimum - 1)
diff_max = abs(X - maximum + 1)
if diff_min == diff_max:
    answer = min(minimum - 1, maximum + 1)
else:
    answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)