#include <bits/stdc++.h>

using namespace std;

int  bsearch(int a[], int n, int br)
{
   int lg=1,dg=n,sredina;

   while(lg <= dg){
        int sredina = lg + (dg - lg) / 2;

        if (a[sredina] == br) {
                if (sredina > n/2) {
                        while(a[sredina-1]==br)
                        sredina--;

                        }
                else {
                    while(a[sredina+1]==br)
                        sredina++;
                }
            return sredina;
        }

        if (a[sredina] < br)
            lg = sredina + 1;

        else
            dg = sredina - 1;
    }

    return -1;
}

int main()
{
    int n,q;
    cin >>n>>q;
    double x=n;
    int apola=floor(x/2)+1;
    int a[n+1], b[q];
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=0;i<q;i++)cin>>b[i];
    sort(a+1,a+n+1);
    for(int i=0;i<q;i++){
        if(b[i]==a[apola])cout<<0<<endl;
        else if(b[i]>a[n])cout<<n<<endl;
        else if(b[i]<a[1])cout<<n+1<<endl;
        else{
            int index=bsearch(a,n,b[i]);
            if(index>apola){
                cout<<((index-1)*2)-n<<endl;
            }
            else cout<<(n-index)-index+1<<endl;
        }
    }
    return 0;
}