#include <bits/stdc++.h>
using namespace std;

int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    long int n,q;
    cin >> n >> q;
    vector<long int> niz(n);

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

    long int b;
    sort(begin(niz),end(niz));
    for(long int i = 0;i < q;i++){
        cin >> b;

        long int l = lower_bound(begin(niz),end(niz),b) - begin(niz);
        long int d = upper_bound(begin(niz),end(niz),b) - begin(niz);

        d = n-d;
        if(niz[l] != b){
            if(l <= d) cout << abs(d-l)+1 << "\n";
            else cout << abs(d-l) << "\n";
        }
        else{
            if(min(l,n-d-1) <= floor(n/2) && floor(n/2) <= max(l,n-d-1)) cout << "0\n";
            else if(l <= d) cout << 2*max(l,d)-n+1 << "\n";
            else cout << 2*max(l,d)-n << "\n";
        }
    }
}