#include <iostream>
#include <algorithm>

using namespace std;
void razmeni(int &a, int &b)
{
    int p=a;
    a=b;
    b=p;
}
void heap(int a[],int n,int i){
    int largest=i,l=2*i+1,d=2*i+2;
    if(l<n && a[l]>a[largest])
       largest=l;
    if(d<n && a[d]>a[largest])
       largest=d;
    if(largest!=i)
    {
        razmeni(a[i],a[largest]);
        heap(a,n,largest);
    }
}
void heapsort(int a[],int n){
    for(int i=n/2 -1;i>=0;i--)
       heap(a,n,i);
    for(int i=n-1;i>=0;i--)
        {
            razmeni(a[0],a[i]);
            heap(a,i,0);
        }
}
bool bp(int a[],int n,int x)
{
    int l=0,d=n-1;
    while(l<=d)
    {
        int s=l+(d-l)/2;
        if(x<a[s])
           d=s-1;
        else
          if(x>a[s])
             l=s+1;
        else return true;
    }
    return false;

}

void upis(int a[],int n)
{
    for(int i=0;i<n;i++)
       cin>>a[i];
}
int main()
{
    int n,q,j=0;
    cin>>n>>q;
    int a[n],b[q],l[q],d[q],o[q];
    upis(a,n);
    heapsort(a,n);

    for(int i=0;i<q;i++){
        cin>>b[i];
        int m=n;
        if(bp(a,n,b[i]))
        {
            while(a[m/2]!=b[i])
               m++;
            o[i]=m-n;}

        else{
        while((b[i]<a[j] || b[i]>a[j+1]) && j<n-1)
           j++;
        l[i]=j+1;
        if(bp(a,n,b[i]))
           d[i]=n-l[i]-1;
        else
           d[i]=n-l[i];
        j=0;
        if(l[i]==d[i] && bp(a,n,b[i]))
          o[i]=0;
        else{
           if(l[i]==d[i])
             o[i]=1;
           if(l[i]>d[i] && bp(a,n,b[i]))
              o[i]=l[i]-d[i]-1;
           else
               if(l[i]>d[i])
                  o[i]=l[i]-d[i];
           if(l[i]<d[i] && bp(a,n,b[i]))
                o[i]=d[i]-l[i];
           else
               if(l[i]<d[i])
                  o[i]=d[i]-l[i]+1;
        ;}}}

    for(int i=0;i<q;i++)
      cout<<o[i]<<endl;








    return 0;
}