#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long lond
#define lli long long int
using namespace std;
ll n,q,a[200005],x;
map <ll,ll> m;
void set1(ll x){ /// ako x vec ima u nizu
    for (int i=1;i<=n;i++){
        if (a[i]==x){
            if (n%2==0){
                if (i>n/2+1) cout << abs(n/2+1-i)*2 << "\n";
                else cout << abs(n/2+1-i)*2-1 << "\n";
            }
            else {
                if (i>n/2+1) cout << abs(n/2+1-i)*2-1 << "\n";
                else cout << abs(n/2+1-i)*2 << "\n";
            }
        }
    }
}
void set2(ll x){
    if (x>a[n] or x<a[1]) cout << n << "\n";

    else {
        n+=1;
        for (int i=1;i<=n-1;i++){
            if (a[i]<x and a[i+1]>x){
                if (n%2==0){
                    if (i>n/2+1){
                        n-=1;
                        cout << abs(n/2+1-i)*2 << "\n";
                    }
                    else{
                        n-=1;
                        cout << abs(n/2+1-i)*2-1 << "\n";
                    }
                }
                else {
                    if (i>n/2+1){
                        n-=1;
                        cout << abs(n/2+1-i)*2-1 << "\n";
                    }
                    else{
                        n-=1;
                        cout << abs(n/2+1-i)*2 << "\n";
                    }
                }
            }
        }
    }
}
int main(){
    scanf("%lld",&n);
    scanf("%lld",&q);
    for (ll i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        m[a[i]]++;
    }
    sort(a+1,a+1+n);
    for (ll i=1;i<=q;i++){
        scanf("%lld",&x);
        if (a[n/2+1]==x) cout << 0 << endl;
        else {
            if (m[x]) set1(x);
            else set2(x);
        }
    }
    return 0;
}