#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int bp(vector<int> a,int p,int n)   {
  int d,l,sr;
  l=0;d=n-1;
  while(l<=d) {
    sr=l+(d-l)/2;
    if (p<a[sr])
      d=sr-1;
    else if(p>a[sr])
      l=sr+1;
    else return sr;
  }
  return -1;}
int main()
{
   int n,q,c,j,k;
   cin>>n>>q;
   int s=n/2+1;
   vector<int>a(n);
   vector<int>b(q);
    vector<int>r(q);
   for(int i=0;i<n;i++)cin>>a[i];
   sort(begin(a),end(a));
   for(int i=0;i<q;i++){
    cin>>b[i];
    c=bp(a,b[i],n);
    if(c==-1){
        for(k=n;k>0&&b[i]<a[k-1];k--){}
        int x,y;
       x=k;
    y=n-k;
    if(y>=x)r[i]=y-x+1;
    else r[i]=x-y;
     }
    else{
    if(c==s)r[i]=0;
   else if(c>s&&a[c]==a[c-1])while(a[c]==a[c-1])c--;
    else while(a[c]==a[c+1])c++;
    int x,y;
    x=c;
    y=n-c-1;
    if(y>=x)r[i]=y-x;
    else r[i]=x-y-1;
    }
   }
for(int i=0;i<q;i++)cout<<r[i]<<endl;
    return 0;
}