using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;

namespace ABC170
{
    using static Ex;
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_C();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var x = ReadIntArray();
            for (int i = 0; i < x.Length; i++)
            {
                if (x[i] == 0)
                {
                    (i + 1).Cw();
                    return;
                }
            }
        }
    }
    public class ABC_B
    {
        //総数はX匹で、それらの足の総数はY本
        int x, y;
        public ABC_B()
        {
            (x, y) = ReadIntArray().ToTpl2();
            for (int i = 0; i <= x; i++)
            {
                var all = 2 * i + 4 * (x - i);
                if (all == y)
                {
                    "Yes".Cw();
                    return;
                }
            }
            "No".Cw();
        }
    }
    public class ABC_C
    {
        int x, n;
        public ABC_C()
        {
            (x, n) = ReadIntArray().ToTpl2();
            if (n == 0)
            {
                x.Cw();
                return;
            }
            var p = ReadIntArray();
            var set = new HashSet<int>(p);

            for (int i = 0; ; i++)
            {
                if (!set.Contains(x - i))
                {
                    (x - i).Cw();
                    return;
                }
                if (!set.Contains(x + i))
                {
                    (x + i).Cw();
                    return;
                }
            }
        }
    }
    public class ABC_D
    {
        int MAX = (int)1e6;
        int n;
        public ABC_D()
        {
            n = ReadInt;
            var a = ReadIntArray();
            var dict = new Dictionary<int, HashSet<int>>();
            var set = new HashSet<int>(a);
            var check = new bool[n];
            for (int i = 0; i < n; i++)
            {
                if (dict.ContainsKey(a[i]))
                    dict[a[i]].Add(i);
                else
                {
                    dict[a[i]] = new HashSet<int>() { i };
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (check[i]) continue;

                if (set.Contains(a[i]))
                {
                    if (dict[a[i]].Count > 1) check[i] = true;
                    foreach (var v in dict[a[i]])
                    {
                        if (v == i) continue;
                        check[v] = true;
                    }
                }

                for (int j = 2; j * a[i] <= MAX; j++)
                {
                    //var k = (a[i] * j); k.Cw();
                    if (set.Contains(a[i] * j))
                    {
                        foreach (var v in dict[a[i] * j])
                            check[v] = true;
                    }
                }
            }
            check.Count(v => !v).Cw();
        }
    }
    public class ABC_E
    {
        /// <summary>
        /// 幼児が N 人おり、 1 から N の番号
        /// 幼稚園が 2 × 10 5 校あり、 1 から 2 × 10 5 の番号
        /// 幼児 i のレートは A i 
        /// はじめ幼稚園 B i に所属
        ///
        /// Q回にわたって、転園
        /// j回目の転園では、幼児Cjの所属を幼稚園Djに変更
        ///
        /// 「平等さ」
        /// 幼児が一人以上いるような幼稚園それぞれについて
        /// 園内で最もレートの高い幼児のレートを求め、その最小値として得られる値とします。
        /// </summary>
        int n, q, a, b, c, d;
        public ABC_E()
        {
            (n, q) = ReadIntArray().ToTpl2();
            var dict = new Dictionary<int, PriorityQueue<(int, int)>>();
            var pq = new PriorityQueue<int>();
            var en = new int[n];
            var rate = new int[n];

            for (int i = 0; i < n; i++)
            {
                (a, b) = ReadIntArray().ToTpl2();

                if (!dict.ContainsKey(b))
                {
                    dict[b] = new PriorityQueue<(int, int)>();
                }
                dict[b].Push((a, i));
                en[i] = b;
                rate[i] = a;
            }
            foreach (var v in dict)
            {
                pq.Push(v.Value.Peek.Item1);
            }
            for (int i = 0; i < q; i++)
            {
                //幼児Cj を 幼稚園Dj に変更
                (c, d) = ReadIntArray().ToTpl2();
                c--;
                if (dict[en[c]].Peek == (rate[c], c))
                {
                    pq.list.Remove(rate[c]);
                    pq.Push(dict[en[c]].Peek.Item1);
                }

                dict[en[c]].list.Remove((rate[c], c));
                en[c] = d;
                (int, int) tmp = (-1, -1);
                if (!dict.ContainsKey(d))
                {
                    dict[d] = new PriorityQueue<(int, int)>();
                }
                else
                {
                    tmp = dict[en[c]].Peek;
                }
                dict[d].Push((rate[c], c));
                if (dict[en[c]].Peek == (rate[c], c))
                {
                    if (tmp.Item1 != -1) pq.list.Remove(tmp.Item1!);
                    pq.Push(rate[c]);
                }
                string.Join(" ", pq.list).Cw();
                pq.list.Last().Cw();
            }
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
        }
    }

    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }



        public static bool Mins<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
        public static bool Maxs<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
        public static void Swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
        public static void Swap<T>(List<T> list, int i, int j) { T tmp = list[j]; list[j] = list[i]; list[i] = tmp; }


        static long Gcd(long m, long n) { if (n == 0) return m; return Gcd(n, m % n); }
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var v = new string[N]; for (long i = 0; i < N; ++i) v[i] = Read; return v; }
        public static int[] ReadIntArray(long N) { var v = new int[N]; for (long i = 0; i < N; ++i) v[i] = ReadInt; return v; }
        public static long[] ReadLongArray(long N) { var v = new long[N]; for (long i = 0; i < N; ++i) v[i] = ReadLong; return v; }

        public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
        public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
        public static (T, T, T, T) ToTpl4<T>(this T[] v) { return (v[0], v[1], v[2], v[3]); }
        public static (T, T, T, T, T) ToTpl5<T>(this T[] v) { return (v[0], v[1], v[2], v[3], v[4]); }


        public class PriorityQueue<T> where T : IComparable<T>
        {
            public List<T> list = new List<T>();
            void PushHeap(T v)
            {
                int n = list.Count;
                list.Add(v);

                while (n != 0)
                {
                    int i = (n - 1) / 2;
                    if (list[n].CompareTo(list[i]) > 0)
                        Swap(list, i, n);
                    n = i;
                }
            }
            void PopHeap()
            {
                int n = list.Count - 1;
                list[0] = list[n];
                list.RemoveAt(n);

                for (int i = 0, j; (j = 2 * i + 1) < n;)
                {
                    if ((j != n - 1) && (list[j].CompareTo(list[j + 1]) < 0))
                        j++;
                    if (list[i].CompareTo(list[j]) < 0)
                        Swap(list, i, j);
                    i = j;
                }
            }
            public void Push(T elem) { PushHeap(elem); }
            public T Pop() { var v = Peek; PopHeap(); return v; }
            public T Peek { get { return list[0]; } }
            public int Count { get { return list.Count; } }
        }
    }
}

Measured memory_bytes: 28364