#include <bits/stdc++.h>

using namespace std;
int prp(int a[],int n,int x){
    for(int i = 0;i<n;i++){
        if(a[i]==x)return i;
    }
    return -1;
}
int pop(int a[],int n,int x){
    for(int i = 0;i<n;i++){
        if(a[i]==x){
            while(a[i]==x)i++;
            return i-1;
        }

    }
    return -1;
}
int main()
{
    int n,q,a[100000000],b[100000000];
    int r;
    scanf("%d%d",&n,&q);
    for(int i = 0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i = 0;i<q;i++){
        scanf("%d",&b[i]);
    }
    sort(a,a+n-1);
    int med,mini,maxi;
    med=a[n/2];
    mini=a[0];
    maxi=a[n-1];
    for(int i = 0;i<q;i++){
        if(b[i]>maxi)printf("%d",n);
        if(b[i]<mini)printf("%d",n+1);
        if(b[i]>med&&b[i]<maxi){
            if(prp(a,n,b[i])!=-1){
                r=prp(a,n,b[i])*2-n;
                printf("%d",r);
            }
            else{
                a[n]=b[i];
                sort(a,a+n);
                r = prp(a,n+1,b[i])*2-n;
                printf("%d",r);
                a[prp(a,n+1,b[i])]=maxi+1;
                sort(a,a+n)
            }
        }
        if(b[i]<med&&b[i]>mini){
           if(pop(a,n,b[i])!=-1){
                r = n-1-pop(a,n,b[i])*2;
                printf("%d",r);
            }
           else{
                a[n]=b[i];
                sort(a,a+n);
                r = n-pop(a,n+1,b[i])*2+1;
                printf("%d",r);
                a[pop(a,n+1,b[i])]=maxi+1;
                sort(a,a+n)
            }
        }
        if(b[i]==med)printf("0");
        printf("\n");
    }
    return 0;
}