#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    int *a=(int*)malloc(n*sizeof(int));
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n);
    for (int i=0;i<q;i++)
    {
        int k;
        scanf("%d",&k);
        int l=0,d=n-1;
        int ii,t=0;
        while (l<d)
        {
            int ll=l;
            int dd=d;
            int mid=(l+d)/2;
            if (a[mid]==k)
            {
                t=1;
                ii=mid;
                break;
            }
            else if (a[mid]<k) l=mid;
            else d=mid;
            ii=mid;
            if (a[d]<=k) ii=d;
            if (ll==l && dd==d) break;
        }
        if (a[ii]>k) ii--;
        //printf("%d\n",ii);
        if (a[ii]==k)
        {
            int br=min(abs(n-2*ii),abs(n-2*ii-1));
            printf("%d\n",br);
        }
        else
        {
            ii++;
            int nn=n+1;
            int br=min(abs(nn-2*ii),abs(nn-2*ii-1))+1;
            printf("%d\n",br);
        }
    }
}