read X N
read str

[ $N -eq 0 ] && { echo $X; exit; }

echo $str | tr " " "\n" > omitfile

seq 1 100 | grep -vx -f omitfile | awk -v X=$X 'function abs(v){return v < 0 ? -v : v} {print $0,abs($0-X) }' | sort -k2,2n -k1,1n | head -1 | cut -d\  -f1
