namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Reflection.PortableExecutable;
    using System.Text;
    using System.Xml.Serialization;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var xn = t.ParseIntList(t.ReadInput());
            var dic = new Dictionary<int, int>();
            var l = int.MaxValue;
            var temp = int.MaxValue;
            var temp2 = int.MaxValue;
            var r = int.MaxValue;
            var ans = int.MaxValue;

            if (xn[1] == 0)
            {
                ans = xn[0];
            }
            else
            {
                var p = t.ParseIntList(t.ReadInput());
                p.ForEach(v => dic.Add(v, v));
                p.Sort();
                //左から
                for (var i = 0; i < p.Count; i++)
                {
                    temp = xn[0] - p[i];
                    if (temp <= 0)
                    {
                        l = p[i];
                        break;
                    }
                }

                //候補が2つの場合右からも
                if (temp < 0)
                {
                    for (var i = p.Count - 1; i > 0; i--)
                    {
                        temp2 = xn[0] - p[i];
                        if (temp2 >= 0)
                        {
                            r = p[i];
                            break;
                        }
                    }
                }
                else
                {
                    r = l;
                }

                //候補が1つの場合
                if (l == r)
                {
                    var loopCount = 1;
                    while (true)
                    {
                        var lm = l - loopCount;
                        var lp = l + loopCount;
                        if (!t.DicSearch(lm, dic))
                        {
                            ans = lm;
                            break;
                        }
                        if (!t.DicSearch(lp, dic))
                        {
                            ans = lp;
                            break;
                        }
                        loopCount++;
                    }
                }
                //2つの場合
                else
                {
                    var loopCount = 1;
                    while (true)
                    {
                        var lm = l + loopCount;
                        var lp = r + loopCount;
                        if (!t.DicSearch(lm, dic))
                        {
                            ans = lm;
                            break;
                        }
                        if (!t.DicSearch(lp, dic))
                        {
                            ans = lp;
                            break;
                        }
                        loopCount++;
                    }
                }
            }
            Console.WriteLine(ans); 
        }

        public bool DicSearch(int x,Dictionary<int,int> dic)
        {
            return dic.ContainsKey(x);
        }


        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 27856