#include <bits/stdc++.h>
#define ll long long
#define MAXN 200010
using namespace std;
ll a[MAXN],n,b[MAXN];
ll Prva(ll x)
{
    ll l=1,r=n,mid,res=0;
    while (l<=r)
    {
        mid=(l+r)/2;
        if (a[mid]==x)
        {
            res=mid;
            r=mid-1;
            continue;
        }
        if (a[mid]>x)
            r=mid-1;
        else
            l=mid+1;
    }
    return res;
}
ll Poslednja(ll x)
{
    ll l=1,r=n,mid,res=0;
    while (l<=r)
    {
        mid=(l+r)/2;
        if (a[mid]==x)
        {
            res=mid;
            l=mid+1;
            continue;
        }
        if (a[mid]>x)
            r=mid-1;
        else
            l=mid+1;
    }
    return res;
}
ll Poslednji_Manji(ll x)
{
    ll l=1,r=n,mid,res=0;
    while (l<=r)
    {
        mid=(l+r)/2;
        if (a[mid]<x)
        {
            res=mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    return res;
}
ll Resi(ll x)
{
    if (a[(n+1)/2]==x)
        return 0;
    ll p=Prva(x),k=Poslednja(x);
    if (p)
    {
        if (k<(n+1)/2)
            return (n+1)/2-k;
        else
            return p-(n+1)/2;
    }
    ll manji=Poslednji_Manji(x),veci;
    veci=n-manji;
    if (manji<=veci)
        return veci-manji+1;
    return manji-veci;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll q;
    cin >> n >> q;
    for (ll i=1;i<=n;i++)
        cin >> a[i];
    sort(a+1,a+1+n);
    for (ll i=1;i<=q;i++)
        cin >> b[i];
    for (ll i=1;i<=q;i++)
        cout << Resi(b[i]) << "\n";
    return 0;
}