#include <bits/stdc++.h>

using namespace std;

int f(int bg, int en, int pos)
{
    int x=pos-bg;
    int y=en-pos-1;
    if(x>y)return x-y-1;
    if(x<y)return y-x;
    return 0;

}

int main()
{

    int n,q;
    vector<int> a;
    scanf("%d %d", &n,&q);
    for(int i=0; i<n; i++)
    {
        int x;
        scanf("%d", &x);
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    for(int i=0; i<q; i++)
    {
        int m,z=0;
        scanf("%d", &m);
        int low =lower_bound(a.begin(), a.end(), m)-a.begin();
        int up = upper_bound(a.begin(), a.end(), m)-a.begin();
        int bg=0;
        int en=a.end()-a.begin();
        if(low==up)
        {
            z=1;
            up++;
            en++;
        }
        int mid=(bg+en)/2;
        if(low<=mid && mid<up)printf("%d\n",z);
        else
        {
            z+=min(f(bg,en,low), f(bg,en,up-1));
            printf("%d\n",z);
        }
    }




    return 0;
}