#include <bits/stdc++.h>

using namespace std;

int n,q;
int a[200010],b[200010];

int donja(int el){
    int l=0,d=n-1;
    while(l<d){
        int m=l+(d-l)/2;
        if(el<=a[m]) d=m;
        else l=m+1;
    }
    if(l<n && a[l]<el) l++;
    return l;
}

int gornja(int el){
    int l=0,d=n-1;
    while(l<d){
        int m=l+(d-l)/2;
        if(el>=a[m]) l=m+1;
        else d=m;
    }
    if(l<n && a[l]<el) l++;
    return l;
}

int binp(int el){
    if(a[donja(el)]==el) return donja(el);
    else return -1;
}

bool moze(int i,int el){
    int l=donja(el);
    int d=gornja(el)-1;
    if(binp(el)==-1) l=d=l;
    int in=(n+i)/2;
    //cerr<<l<<" "<<d<<"\n";
    if(binp(el)==-1) i--;
    if(l>in) return false;
    if(d+i<in) return false;
    return true;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>q;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<q;i++) cin>>b[i];
    sort(a,a+n);
    //for(int i=0;i<n;i++) cout<<a[i]<<" ";
    //cout<<"\n";
    for(int i=0;i<q;i++){
        int l,d; l=0,d=3*n;
        int el=b[i];
        while(l<d){
            int m=(l+d)/2;
            if(moze(m,el)) d=m;
            else l=m+1;
        }
        cout<<l<<"\n";
    }
    
    return 0;
}