#include <bits/stdc++.h>

using namespace std;
vector<long long> a,b;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n,q,p;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        cin>>p;
        a.push_back(p);
    }
    for(int i=0;i<q;i++){
        cin>>p;
        b.push_back(p);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<q;i++){
        if(binary_search(a.begin(),a.end(),b[i])){
            long long l=upper_bound(a.begin(),a.end(),b[i])-a.begin()-1;
            long long r=lower_bound(a.begin(),a.end(),b[i])-a.begin();
            long long m=n/2;
            if(m>=l && m<=r)
                cout<<0<<"\n";
            else if(r<=m)
                cout<<n-r-r-1<<"\n";
            else if(l>=m)
                cout<<l+l-n<<"\n";
        }
        else{
            long long r=lower_bound(a.begin(),a.end(),b[i])-a.begin();
            long long m=(n+1)/2;
            if(m==r)
                cout<<1<<"\n";
            else if(r<=m)
                cout<<n-r-r+1<<"\n";
            else if(r>=m)
                cout<<r+r-n<<"\n";
        }
    }
    return 0;
}