#include<bits/stdc++.h>
using namespace std;
int n,q;
int a[1000100],b[1000100],br;
int medijana1, medijana2, rez1, rez2, medijanat1, medijanat2,mid,low,high;
int i=1, j=1;
///medijana-j
int main ()
{
    cin >> n >> q;

    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
    }

    for(int i=1; i<=q; i++)
    {
        cin >> b[i];
    }

    sort(a,a+n+1);


	 if(n%2!=0)
	 {

	 medijana1=n/2+1;

		 for(i=1; i<=q; i++)
		 {
		 	low=1;
		 	high=n;
			  while(true)
			  {
                   mid = (low + high)/2;
                   if (b[i] == a[mid])
						 {
						    cout <<abs(medijana1-mid) << endl;
							 goto ovde;
						 }
						 if(low==high)
						 {
						 	break;
						 }
                   else if (b[i] > a[mid])
						 {
                       low = mid + 1;
						 }
                   else
						 {
                       high = mid - 1;
						 }

			  }

			  a[n+1]=b[i];
			  sort(a,a+n+2);
			  goto ponavljanje;
			  vracanje:
			  ovde:
			  if(i==q)
			  {
			  	return 0;
			  }

		 }
	 }

    ponavljanje:
    medijanat1=(n+1)/2;
    medijanat2=(n+1)/2+1;
    ///Postaje parno

		rez1=abs(medijanat1-b[i]+1);
		rez2=abs(medijanat2-b[i]+1);
		cout << min(rez1, rez2) << endl;
		goto vracanje;


    ///Od pocetka parno, postace neparno
    if(n%2==0)
	 {
			 medijana1=n/2;
			 medijana2=n/2+1;

		for(i=1; i<=q; i++)
		 {
		 	low=1;
		 	high=n;
			  while(low!=high)
			  {
                   mid = (low + high)/2;
                   if (b[i] == a[mid])
						 {
						    rez1=abs(medijana1-mid);
						    rez2=abs(medijana2-mid);
						    cout << min(rez1,rez2) << endl;
							 goto ovde1;
						 }
						 if(i==mid)
						 {
						 	break;
						 }
                   else if (b[i] > a[mid])
						 {
                       low = mid + 1;
						 }
                   else
						 {
                       high = mid - 1;
						 }
			  }
						  a[n+1]=b[i];
							sort(a,a+n+2);
							goto ponavljanje1;

						vracanje1:
						ovde1:
					if(i==q)
					{
						return 0;
					}

		 }
	 }

	 ponavljanje1:
	 medijanat1=(n+1)/2+1;
	cout <<abs(medijanat1-j) << endl;
	goto vracanje1;
}