using System;
using System.Collections;
using System.Collections.Generic;

class Program {

    static void Main (string[] args) {
        string[] strtemp1 = Console.ReadLine ().Split (' ');
        long X = long.Parse (strtemp1[0]);
        int N = int.Parse (strtemp1[1]);
        var parray = new long[N];
        string[] strtemp2 = Console.ReadLine ().Split (' ');
        for (int i = 0; i < N; i++) {
            parray[i] = long.Parse (strtemp2[i]);
        }

        QuickSortS2B (parray);
        long binaryreturn = BinarySearch (parray, X);

        if (binaryreturn == -1) {
            Console.WriteLine (X);
        } else {
            bool found = false;
            long absdif = 1;
            while (!found) {
                if (binaryreturn - absdif >= 0) {
                    if (parray[binaryreturn - absdif] != parray[binaryreturn] - absdif) {
                        found = true;
                        Console.WriteLine (parray[binaryreturn] - absdif);
                        break;
                    }
                } else {
                    found = true;
                    Console.WriteLine (parray[binaryreturn] - absdif);
                    break;
                }
                if (binaryreturn + absdif < parray.Length) {
                    if (parray[binaryreturn + absdif] != parray[binaryreturn] + absdif) {
                        found = true;
                        Console.WriteLine (parray[binaryreturn] + absdif);
                        break;
                    }
                } else {
                    found = true;
                    Console.WriteLine (parray[binaryreturn] + absdif);
                    break;
                }
                absdif++;
            }
        }
    }

    static void QuickSortS2B (long[] a) {
        QuickSortS2B (a, 0, a.Length - 1);
    }

    static void QuickSortS2B (long[] a, int left, int right) {
        if (left < right) {
            int i = left;
            int j = right;
            long tmp;
            long pivot = med3 (a[i], a[i + (j - i) / 2], a[j]);
            while (true) {
                while (a[i] < pivot) i++;
                while (pivot < a[j]) j--;
                if (i >= j) break;
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
                i++;
                j--;
            }
            QuickSortS2B (a, left, i - 1);
            QuickSortS2B (a, j + 1, right);
        }
    }

    static long med3 (long x, long y, long z) {
        if (x < y) {
            if (y < z) {
                return y;
            } else if (z < x) {
                return x;
            } else {
                return z;
            }
        } else {
            if (z < y) {
                return y;
            } else if (x < z) {
                return x;
            } else {
                return z;
            }
        }

    }

    static long BinarySearch (long[] array, long target) {
        long min = 0;
        long max = array.Length - 1;

        while (min <= max) {
            long mid = min + (max - min) / 2;
            if (target > array[mid]) {
                min = mid + 1;
            } else if (target < array[mid]) {
                max = mid - 1;
            } else {
                return mid;
            }
        }
        return -1;
    }
}

//dotnet run --project test

Measured memory_bytes: 27488