#include <bits/stdc++.h>

using namespace std;

long long n, u;
long long niz[200000];

int resi(long long m){
    long long l = 0, r = n -1;

    while(abs(l-r) > 1){
        long long mid = (l + r) / 2;
        if(niz[mid] == m) return mid;
        if(niz[mid] > m) r = mid;
        else l = mid;
    }
    return l;
}

int main()
{
    cin >> n >> u;
    queue<int> q;

    for(int i = 0 ; i < n ; i++) cin >> niz[i];
    sort(niz, niz+n);

    for (int i = 0 ; i < u ; i++)
    {
        long long k;
        cin >> k;
        q.push(k);
    }

    while(!q.empty()){
        long long m = q.front(), mid = niz[int(ceil(n/2.0))-1];

        q.pop();
        long long index = resi(m);


        if (index == 0 && m < niz[index]) index--;


        if (mid == niz[index])
            cout << 0<< endl;
        else{
            if(mid > niz[index] && niz[index] == m){
                while(niz[index] == m){index++;}
                index--;
            }
            if(mid < niz[index] && niz[index] == m){
                while(niz[index] == m){index--;}
                index++;
            }

            cout<<index;
            if(index == -1) cout << n-2*(index + 1) <<endl;

            else if(index < int(ceil(n/2.0))-1 && m == niz[index] ) cout << n-(index+1)-index <<endl;

            else if(index < int(ceil(n/2.0))-1 && m != niz[index]) cout << n-2*(index + 1) <<endl;

            else if(index > int(ceil(n/2.0))-1 && m == niz[index]) cout << n-(index+1)-index - 1<<endl;

            else cout <<  n-2*(index + 1) - 1 <<endl;
        }
    }
}