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

int main(void)
{
	int X, Y,big, flug,i, str[100];

	for (i = 0; i < 100; i++)
	{
		str[i] = 0;
	}
	scanf("%d%d", &X, &Y);
	for(i=0;i<=Y;i++)
	{
		scanf("%d", &str[i]);
	}
	if (Y == 0)
	{
		printf("%d", X);
	}
	else
	{
		for (i = 0; i < Y; i++)
		{
			while (flug == 0)
			{
				big = str[i];
				flug = 1;
			}
			if (flug == 1 && abs(big - X)  < abs(str[i] - X) )
			{
				big = str[i];
			}
		}
		printf("%d", big);
	}
	return 0;
}