#include <bits/stdc++.h>
#define int long long
using namespace std;
int prvi(int a[], int l, int r, int b, int n)
{
    if (r >= l) {
        int mid=l+(r-l)/2;
        if((mid==0||b>a[mid-1])&&a[mid]==b)
            return mid;
        else if(b>a[mid])return prvi(a,(mid + 1),r,b,n);
        else return prvi(a,l, (mid - 1), b, n);
    }
    return 0;
}

int blizu(int b, int a[],int n){
    if(b>a[n-1])return n;
    else if(b<a[0])return 0;
    else{
        int l=0;
        int r=n-2;
        while(l<=r){
            int mid=l+(r-l)/2;
            if(a[mid+1]<b){
                 l=mid+1;
            }
            else if(a[mid]>b)r=mid-1;
            else return mid+1;

        }
    }
}


signed main()
{
    int n,q;
    cin>>n>>q;
    map<int,int> m;
    int a[n];
    for(int i=0; i < n; i++){
        cin>>a[i];
    }

    sort(a,a+n);
    for(int i=0; i < n; i++){
            m[a[i]]=i;
        }


    while(q--){
        int b;
        cin>>b;
         if(m.find(b)!=m.end()){
            int l=prvi(a,0,n-1,b,n);
            int r=m[b];
            //cout<<l<<" "<<r<<'\n';
            if(r==0)r=l;
            if(l==0)l=r;
            if(n/2>=l && n/2<=r){
                cout << 0 <<"\n";
            }
            else{
                if(n/2>r){
                    if(n%2==0)cout<<2*(n/2-r)-1<<"\n";
                    else cout<< 2*(n/2-r)<<"\n";
                }
                else if(n/2<l){
                    if(n%2==0)cout<<2*(l-n/2)<<"\n";
                    else cout<<2*(l-n/2)-1<<"\n";
                }
            }
         }
         else{
              int id=blizu(b,a,n);

              //cout<<"indeks"<<id<<"\n";

               int md=(n+1)/2;
              // cout<<"md: "<<md<<"\n";
            if(id==md)cout<<1<<"\n";

            else{
                if(id>md){
                    if(n%2==1)cout << 2*(id-md)+1<<"\n";
                    else cout<< 2*(id-md)<<"\n";

                }
                else{
                    if(n%2==1) cout << 2*(md-id)<<"\n";

                    else cout << 2*(md-id) +1 <<"\n";
                }
            }
        }
            }
         }