#include <bits/stdc++.h>

#define xx first
#define yy second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mp make_pair
#define pb push_back
#define popb pop_back
#define ez {cout << "NO\n"; return;}

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef string str;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX=1e6+3;
int n, t, x;
int a[MAX];


inline void solve(){
    cin >> x;
    int pos=lower_bound(a, a+n, x)-a;
    int nxpos=upper_bound(a, a+n, x)-a;
    int l=0, r=MAX*10, mid;
    while(l<r){
        //cout << l << " " << r << ": ";
        mid=l+(r-l)/2;
        int med=(mid+n)/2;
        //cout << mid << " <-> " << med << "\n";
        if(mid==0 && pos==nxpos){
            l=mid+1;
            continue;
        }
        if(mid+nxpos-1>=med && pos<=med){
            r=mid;
        }
        else l=mid+1;
    }
    cout << r << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n >> t;
    for(int i=0;i<n;++i) cin >> a[i];
    sort(a, a+n);
    while(t--) solve();
    return 0;
}