#include <bits/stdc++.h>

using namespace std;

vector<int> a;
int n;

int sled(int x,int d)
{
    int l=0;

    int res=n;
    while(l<=d)
    {
        int mid=(l+d)/2;
        if (a[mid]<=x)
            l=mid+1;
        else
        {
            res=mid;
            d=mid-1;
        }
    }

    return res;
}

int pros(int x,int d)
{
    if(d==0) return -1;
    if(x>a[d-1]) return n-1;

    int l=0;

    int res=-1;
    while (l<=d)
    {
        int mid=(l+d)/2;
        if(a[mid]>=x)
        {
            d=mid-1;
        }
        else
        {
            res=mid;
            l=mid+1;
        }
    }
    return res;
}
int main()
{
    int q,x,b;
    cin>>n>>q;
    set<int> s;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        a.push_back(x);
        s.insert(x);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<q;i++)
    {
        cin>>b;
        int brj,brm,brv;
        brv=n-sled(b,n-1);
        if(s.find(b)!=s.end())
        {
            brm=pros(b,n-1)+1;
            brj=n-brv-brm;
        }
        else
        {
            brm=n-brv;
            brj=0;
        }
        if(a[n/2]==b)
        {
            cout<<0<<endl;
        }
        else
        {
            if(brv>=(brm+brj)) cout<<brv-brm-brj+1<<endl;
            else if(brm>(brv+brj)) cout<<brm-brv-brj<<endl;

        }
    }
    return 0;
}