#include <stdio.h>
#define max(a, b) ((a) > (b) ? (a) : (b))


int main(void){
    int x, n, p[101], f, tmp, q[101];
    int i;
    scanf("%d%d", &x, &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", q + i);
        p[i] = max(q[i] - x, x - q[i]);
    }
    
    f = 0;
    while (f == 0)
    {
        f = 1;
        for (i = 0; i < n - 1; i++)
        {
            if (p[i] > p[i + 1])
            {
                f = 0;
                p[i] ^= p[i + 1];
                p[i + 1] ^= p[i];
                p[i] ^= p[i + 1];
            }
        }
    }
tmp = -1;

    if (p[0] > 0)
    {
        printf("%d", x);
        return (0);
    }    
    
    
    
    

    
    
    
    

    for (i = 1; i < n - 1; i++)
    {
        if (p[i + 1] != p[i])
        {
            tmp = p[i];
            break;
        }
        i++;
        if (p[i + 1] > p[i] + 1)
        {
            tmp = p[i] + 1;
            break;
        }
    }
    if (p[1] > 1)
    {
        tmp = 1;
    }
    for (i = 0; i < n; i++)
    {
        if (max(q[i] - x, x - q[i]) == tmp)
        {
            printf("%d", x + x - q[i]);
            return (0);
        }
    }
    for (i = 0; i < n; i++)
    {
        if (q[i] == x + n / 2 + 1)
        {
            printf("%d", x - n / 2 - 1);
            return (0);
        }
    }
    if (tmp != -1)
    {
        printf("%d", x - tmp);
        
    }
    else
        printf("%d", x + n/ 2 + 1);

    return(0);
}
