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

int n, q;
int a[200010];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n >> q;
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);
    while(q--) {
        int x; cin >> x;
        int l=lower_bound(a, a+n, x)-a;
        int r=upper_bound(a, a+n, x)-a-1;
        int lo=0, hi=300000;
        while(lo<=hi) {
            int mid=(lo+hi)/2;
            if(l<=(n+mid)/2 && (n+mid)/2<=r+mid) hi=mid-1;
            else lo=mid+1;
        }
        cout << lo << endl;
    }
    return 0;
}