#include <bits/stdc++.h>
using namespace std;
using namespace std;
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
#define A first
#define B second
#define PB push_back
#define MP make_pair
#define all(v) v.begin(),v.end()
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

int main()
{
    FAST
    int n,q;
    cin>>n>>q;
    int a[n];
    map<int,pair<bool,int>> bilo;
    map<int,int> pIx;
    map<int,int> kIx;
    map<int,bool> ima;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ima[a[i]]=true;
    }
    sort(a,a+n);
    pIx[a[0]]=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]!=a[i-1])
        {
            kIx[a[i-1]]=i-1;
            pIx[a[i]]=i;
        }

    }
    kIx[a[n-1]]=n-1;
    ///medijana je v/2+1
    for(int i=0;i<q;i++)
    {
        int br=0;
        int v=n;
        int x;
        cin>>x;
        pair<bool,int> p=bilo[x];
        if(p.A)
        {
            cout<<p.B<<endl;
            continue;
        }
        int l=kIx[x];
        bool ok=ima[x];
        if(!ima[x])
        {
            ima[x]=true;
            br++;
            v++;
            pIx[x]=n;
            kIx[x]=n;
            for(int i=0;i<n-1;i++)
            {
                if(a[i]<x && a[i+1]>x)
                {
                    pIx[x]=i+1;
                    kIx[x]=i+1;
                }
            }
        }
        while(true)
        {
            int o=v/2;
            if(o>=pIx[x] && o<=kIx[x]) break;
            kIx[x]++;
            v++;
            br++;
        }
        p.A=true;
        p.B=br;
        bilo[x]=p;
        cout<<br<<endl;
        kIx[x]=l;
        ima[x]=ok;
        if(!ok) pIx[x]=0;
    }
    return 0;
}