#include <bits/stdc++.h>

using namespace std;

int n, q;

int a [200000];
int b [200000];


int main()
{
    ios_base::sync_with_stdio(false);

    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);
    int x;
    int l, u;
    for (int i=0; i<q; i++){
        x=b[i];
        if (x<a[0]){
            cout << n+1 << "\n";
            continue;
        }
        if(x>a[n-1]){
            cout << n << "\n";
            continue;
        }
        auto low = lower_bound(a, a+n, x);
        auto upp = upper_bound(a, a+n, x);
        l = low - a;
        u = upp - a;
        if (l==u){
            if (l<n-l){
                cout << 1+n-2*l << "\n";
                continue;
            }
            else {
                cout << 2*l-n << "\n";
                continue;
            }
        }
        else{
            if (u<=n-u){
                cout << 1+n-2*u << "\n";
                continue;
            }
            else{
                if(l>n-l){
                    cout << 2*l-n << "\n";
                }
                else cout << "0\n";
            }
        }
    }
    return 0;
}