Код:
input()# размер не нужен
arr = list(map(int, input().split()))
x = int(input())
min = arr[0]
for i in arr:
if abs(x - i) < abs(x - min) or (abs(x - i) == abs(x - min) and i < min):
min = i
print(min)
Код:
input()# размер не нужен
arr = list(map(int, input().split()))
x = int(input())
min = arr[0]
for i in arr:
if abs(x - i) < abs(x - min) or (abs(x - i) == abs(x - min) and i < min):
min = i
print(min)