#include <bits/stdc++.h>

using namespace std;

int n,q;
int a[200010];
int b[200010];

int donja(int el){
    int l=0,d=n-1;
    while(l<d){
        int m=(l+d)/2;
        if(a[m]>el) d=m-1;
        else if(a[m]<el) l=m+1;
        else d=m;
    }
    return l;
}

int gornja(int el){
    int l=0,d=n-1;
    while(l<d){
        int m=(l+d)/2;
        if(a[m]<el) l=m+1;
        else if(a[m]>el) d=m;
        else l=m+1;
    }
    return l;
}

int binp(int el){
    if(a[donja(el)]==el) return donja(el);
    else return -1;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>q;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<q;i++) cin>>b[i];
    sort(a,a+n);
    for(int i=0;i<q;i++){
        int el=b[i];
        if(binp(el)!=-1){
            int l=donja(el);
            int d=gornja(el)-1;
            int numtr=d-l+1;
            int manji=l;
            int veci=n-d-1;
            if(manji>veci+numtr) cout<<manji-veci-numtr;
            else if(veci>manji+numtr-1) cout<<veci-manji-numtr+1;
            else cout<<0;
        }else{
            int l;
            if(el>a[n-1]) l=n;
            else l=donja(el);
            int numtr=1;
            int manji=l;
            int veci=n-l-1;
            if(manji>veci+numtr) cout<<manji-veci-numtr;
            else if(veci>manji+numtr-1) cout<<veci-manji-numtr+1;
            else cout<<0;
        }
        cout<<"\n";
    }
    return 0;
}