program malls;
const MAX=100000;
type elenco = array[0..Max-1] of qword;
var N, i :longint;
    D : elenco;
    K, maxdist, pos : qword;
    
procedure scambia (var x,y: qword);
var t:qword;
begin
   t:=x;
   x:=y;
   y:=t;
end;  
Procedure ordinamento (estremoi,estremos: qword; var v : elenco; ordinato:boolean);
var inf, sup, medio:qword;
    pivot : qword;
begin
    inf:=estremoi;
    sup:=estremos;
    medio:= (estremoi+estremos) div 2;
    pivot:=v[medio];
    repeat
      if (ordinato) then
         begin
            while (v[inf]<pivot) do  inf:=inf+1;
            while (v[sup]>pivot) do  sup:=sup-1;
         end;
      if inf<=sup then
       begin
         scambia(v[inf],v[sup]);
         inf:=inf+1;
         sup:=sup-1;
       end;
    until inf>sup;
    if (estremoi<sup) then ordinamento(estremoi,sup,v,ordinato);
    if (inf<estremos) then ordinamento(inf,estremos,v,ordinato);
end; 
begin
	readln(N,K);
	for i:=0 to N-1 do read(D[i]); readln;
	maxdist:=0;
	ordinamento (0,N-1,D, true);
	for i:= 0 to n - 1 do
	                begin
	                	 if (D[i + 1] - D[i]) >= maxdist then 
	                                                begin 
	                                                 maxdist := D[i + 1] - D[i];
                                                     pos := D[i];
                                                    end;
    					if ((D[0] <> 0) and (D[0] >= max/2)) then
                                         begin
                                          maxdist := 0;
                                          pos := 0;
                                         end;
    					if (k - D[n - 1]) >= max/2 then
                                if (k - D[n - 1]) >= D[0] then 
                                                            begin
                                                              maxdist := 0;
                                                              pos := k;
                                                            end;
                   end;                                                 
    writeln ((max div 2 +1) + pos);
end.