Buggy python submission (verdict: Runtime Error):
a = input().split()
b = int(a[0])
c = int(a[1])
d = [int(i) for i in input().split()]
e = sorted(d)


f = int(e[0]-1)
g = int(e[-1]+1)


h = int(g-f)

X = []
for I in range(int(h+1)):
    J = int(f+I)
    if e.count(J) == 0:
        X.append(J)

Y = len(X)
H = []
for S in range(Y):
    Q = X[S]
    if Q>=b:
        g = Q-b
        H.append(g)
    else:
        g = b-Q
        H.append(g)
P = sorted(H)
F = P[0]
O = H.index(F)


print(X[O])

Fixed submission:
a = input().split()
b = int(a[0])
c = int(a[1])
if c == 0:
    print(b)
    
else:
    d = [int(i) for i in input().split()]
    e = sorted(d)


    f = int(e[0]-1)
    g = int(e[-1]+1)


    h = int(g-f)

    X = []
    for I in range(int(h+1)):
        J = int(f+I)
        if e.count(J) == 0:
            X.append(J)

    Y = len(X)
    H = []
    for S in range(Y):
        Q = X[S]
        if Q>=b:
            g = Q-b
            H.append(g)
        elif Q<=b:
            g = b-Q
            H.append(g)
    
    P = sorted(H)
    F = P[0]
    O = H.index(F)


    print(X[O])

Buggy python submission (verdict: Runtime Error):
a = input().split()
b = int(a[0])
c = int(a[1])
d = [int(i) for i in input().split()]
e = sorted(d)


f = int(e[0]-1)
g = int(e[-1]+1)


h = int(g-f)

X = []
for I in range(int(h+1)):
    J = int(f+I)
    if e.count(J) == 0:
        X.append(J)

Y = len(X)
H = []
for S in range(Y):
    Q = X[S]
    if Q>=b:
        g = Q-b
        H.append(g)
    else:
        g = b-Q
        H.append(g)
P = sorted(H)
F = P[0]
O = H.index(F)


print(X[O])
print(X)
print(H)
print(O)

Fixed submission:
a = input().split()
b = int(a[0])
c = int(a[1])
if c == 0:
    print(b)
    
else:
    d = [int(i) for i in input().split()]
    e = sorted(d)


    f = int(e[0]-1)
    g = int(e[-1]+1)


    h = int(g-f)

    X = []
    for I in range(int(h+1)):
        J = int(f+I)
        if e.count(J) == 0:
            X.append(J)

    Y = len(X)
    H = []
    for S in range(Y):
        Q = X[S]
        if Q>=b:
            g = Q-b
            H.append(g)
        elif Q<=b:
            g = b-Q
            H.append(g)
    
    P = sorted(H)
    F = P[0]
    O = H.index(F)


    print(X[O])

Buggy python submission (verdict: Runtime Error):
a = input().split()
b = int(a[0])
c = int(a[1])
d = [int(i) for i in input().split()]
e = sorted(d)


f = int(e[0]-1)
g = int(e[-1]+1)


h = int(g-f)

X = []
for I in range(int(h+1)):
    J = int(f+I)
    if e.count(J) == 0:
        X.append(J)

Y = len(X)
H = []
for S in range(Y):
    Q = X[S]
    if Q>=b:
        g = Q-b
        H.append(g)
    else:
        g = b-Q
        H.append(g)
P = sorted(H)
F = P[0]
O = H.index(F)
W = H.count(F)

    
    
    
print(X[O])
        

Fixed submission:
a = input().split()
b = int(a[0])
c = int(a[1])
if c == 0:
    print(b)
    
else:
    d = [int(i) for i in input().split()]
    e = sorted(d)


    f = int(e[0]-1)
    g = int(e[-1]+1)


    h = int(g-f)

    X = []
    for I in range(int(h+1)):
        J = int(f+I)
        if e.count(J) == 0:
            X.append(J)

    Y = len(X)
    H = []
    for S in range(Y):
        Q = X[S]
        if Q>=b:
            g = Q-b
            H.append(g)
        elif Q<=b:
            g = b-Q
            H.append(g)
    
    P = sorted(H)
    F = P[0]
    O = H.index(F)


    print(X[O])

Buggy python submission (verdict: Runtime Error):
a = input().split()
b = int(a[0])
c = int(a[1])
d = [int(i) for i in input().split()]
e = sorted(d)


f = int(e[0]-1)
g = int(e[-1]+1)


h = int(g-f)

X = []
for I in range(int(h+1)):
    J = int(f+I)
    if e.count(J) == 0:
        X.append(J)

Y = len(X)
H = []
for S in range(Y):
    Q = X[S]
    if Q>=b:
        g = Q-b
        H.append(g)
    else:
        g = b-Q
        H.append(g)
P = sorted(H)
F = P[0]
O = H.index(F)
print(X[O])

Fixed submission:
a = input().split()
b = int(a[0])
c = int(a[1])
if c == 0:
    print(b)
    
else:
    d = [int(i) for i in input().split()]
    e = sorted(d)


    f = int(e[0]-1)
    g = int(e[-1]+1)


    h = int(g-f)

    X = []
    for I in range(int(h+1)):
        J = int(f+I)
        if e.count(J) == 0:
            X.append(J)

    Y = len(X)
    H = []
    for S in range(Y):
        Q = X[S]
        if Q>=b:
            g = Q-b
            H.append(g)
        elif Q<=b:
            g = b-Q
            H.append(g)
    
    P = sorted(H)
    F = P[0]
    O = H.index(F)


    print(X[O])