#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int n;
int index(int x){
    int l = 0;
    int r = n-1;
    int in = -1;
    while(l<r){
        int mid = (l+r)/2;
        if(a[mid]>x) r = mid;
        else if(a[mid]<x) l = mid+1;
        else{
            l = mid;
            break;
        }
    }
    if(x>a[n-1]) l++;
    return l;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    cin>>n;
    int q;
    cin>>q;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    map<int,bool> ima;
    map<int,int> najl;
    map<int, int> najd;
    for(int i=0;i<n;i++){
        ima[a[i]] = true;
        najd[a[i]] = i;
    }
    for(int i=n-1;i>=0;i--) najl[a[i]] = i; 
    for(int i=0;i<q;i++){
        int x;
        cin>>x;
        if(ima[x]){
            int in;
            if(najl[x]>n/2) in = najl[x];
            else if(najd[x]<n/2) in = najd[x];
            else in = n/2;
            if(in==n/2){
                cout<<0<<endl;
                continue;
            }
            if(in<n/2){
                if(n%2==1){
                    cout<<2*(n/2-in)<<endl;
                }
                if(n%2==0){
                        cout<<1+(n/2-1-in)*2<<endl;
                }
            }
            if(in>n/2){
                if(n%2==1){
                    cout<<1+(in-n/2-1)*2<<endl;
                }
                else cout<<2*(in-n/2)<<endl;
            }        
    }
    else{
        int in = index(x);
        n++;
            if(in==n/2){
                cout<<1<<endl;
                n--;
                continue;
            }
            if(in<n/2){
                if(n%2==1){
                    cout<<2*(n/2-in)+1<<endl;
                }
                if(n%2==0){
                        cout<<1+(n/2-1-in)*2+1<<endl;
                }
            }
            if(in>n/2){
                if(n%2==1){
                    cout<<2+(in-n/2-1)*2<<endl;
                }
                else cout<<2*(in-n/2)+1<<endl;
            }   
            n--;
    }
}
}