#include <bits/stdc++.h>

using namespace std;
static int A[200001];
int n;
void resi(int d)
{int sr=n/2+1,mini=-1,maxi=-1;
bool isti=false;
    if(A[sr]==d){cout<<"0\n";return;}
    if(A[n]<d){cout<<n<<"\n";return;}
    if(A[1]>d){cout<<n+1<<"\n";return;}
    for(int i=1;i<=n;i++)
    {
        if(A[i]==d&&!isti){mini=i;isti=true;}
        if(A[i]>d)
        {
            if(A[i-1]==d){maxi=i-1;break;}
            else {cout<<abs(sr-i)+1;return;}
        }
    }
if(maxi==-1){cout<<n/2;return;}
if(maxi==1){cout<<n/2+1;return;}
cout<<min(abs(sr-mini),abs(sr-maxi))<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
int q,x;

cin>>n>>q;
for(int i=1;i<=n;i++)
cin>>A[i];
sort (A,A+n);
for(int i=0;i<q;i++)
{
    cin>>x;
    resi(x);
}

    return 0;
}