#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(int argc, char *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    map<ll,ll>imam;
    ll n,q;
    cin >> n >> q;
    vector<ll>V(n);
    for(ll i=0;i<n;i++)
    {
        cin >> V[i];
        imam[V[i]]++;
    }
    sort(V.begin(),V.end());
    while(q--)
    {
        ll x,l=0,r=n-1,ans=-1;
        cin >> x;
        if(V[n/2]==x)
        {
            cout << 0 << endl;
            continue;
        }
        while(l<=r)
        {
            ll mid=(l+r)/2;
            if(V[mid]<x)
            {
                ans=mid;
                l=mid+1;
            }
            else r=mid-1;
        }
        ans++;
        ll y=n-ans-imam[x];
        ll kolko=imam[x];
        if(ans<y)
        {
            if(imam[x]>=y-ans)
            {
                kolko-=y-ans;
                ans=y;
            }
            else
            {
                ans+=kolko;
                kolko=0;
            }
        }
        else
        {
            if(imam[x]>=ans-y)
            {
                kolko-=ans-y;
                y=ans;
            }
            else
            {
                y+=kolko;
                kolko=0;
            }
        }
        ans+=kolko/2;
        y+=(kolko+1)/2;
        if(ans<n/2+1) cout << abs(ans-y)+1 << endl;
        else cout << abs(ans-y) << endl;
    }
}