#include <fstream>
#include <cmath>

using namespace std;

int main()
{
	ifstream f("GANMNHAT.INP"); 
	ofstream g("GANMNHAT.OUT");
	static long long int i,n,m,a,min;
	f >> n >> m;
	min = 1000000000;
	for (i=1; i<=n; i++)
	{
		f >> a;
		if ((abs(a-m) < abs(min-m)) || ((abs(a-m) == abs (min-m))&&(a<min))) min = a;
	}
	g << min;
	f.close(); g.close();
}
