#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int a, b, ab=1000,temp, ans,sum, n, x;
	int p[105];
	char s[4], t[20];
	scanf("%d %d", &x, &n);
		
	for (int i = 0;i < 102;i++)
		p[i] = i;

	for (int i = 0;i < n;i++) {
		scanf("%d", &a);
		p[a] = 1000;
	}

	ab = abs(x+1);
	ans = -1;

	for (int i = 0;i < 102;i++) {
		temp = abs(x-p[i]);
		if (temp < ab) {
			ans = p[i];
			ab = temp;
		}

	}


	printf("%d",ans);

	return 0;
}