#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define PI acos(-1)
#define LSB(i) ((i) & -(i))
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define MOD 1000000007
#define endl "\n"

#define all(data)       data.begin(),data.end()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
#define ima_li_te(D,d)  find(all(D),d)
#define MAXN 200007
vector<ll> a,b;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,q,ww; cin>>n>>q;
    a.pb(-LLONG_MAX);
    for(int i=1;i<=n;i++)
    {
        cin>>ww; a.pb(ww);
    }
    for(int i=0;i<q;i++)
    {
        cin>>ww; b.pb(ww);
    }
    sort(all(a));
    for(int i=0;i<q;i++)
    {
        ll x=b[i],rez=0,l=1,r=n;
        ll itr1=lower_bound(all(a),x)-a.begin();
        ll itr2=upper_bound(all(a),x)-a.begin();
        if(a[itr1]!=x)
        {
            rez++; r++;
            itr2=itr1;
        }
        else itr2--;
        ll m=r/2+1;
        if(m<itr1)
        {
            ll t=2*(itr1-1)-r-1;
            if((r+t)/2+1>=itr1+t) rez+=t;
            else rez+=t+1;
        }
        else if(itr2<m)
        {
            ll t=r-2*(itr2-1)-1;
            if((r+t)/2+1<=itr2+t) rez+=t;
            else rez+=t+1;
        }
        cout<<rez<<endl;
    }
    return 0;
}