unittest
{
	assert( [ "6 5", "4 7 10 6 5" ].parse.expand.solve == 8 );
	assert( [ "10 5", "4 7 10 6 5" ].parse.expand.solve == 9 );
	assert( [ "100 0", "" ].parse.expand.solve == 100 );
	
	assert( [ "1 2", "1 2" ].parse.expand.solve == 0 );		// 追加ケース
	assert( [ "100 2", "99 100" ].parse.expand.solve == 101 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto xn = input.front.split.to!( long[] );
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	return tuple( xn[ 0 ], ps );
}

auto solve( long x, long[] ps )
{
	auto ans = 0L;
	auto d = x;
	auto ps_s = ps.sort();
	foreach( i; 1L .. 102L )
	{
		if( !ps_s.equalRange( i ).empty ) continue;
		auto dd = abs( x - i );
		if( dd < d )
		{
			d = dd;
			ans = i;
		}
	}
	return ans;
}
