#include <bits/stdc++.h>
#define ll long long
using namespace std;

int fnd_first(int arr[], int n, int x)
{
    int l = 0, d = n-1;
    while(l<=d)
    {
        int s = l + (d-l)/2;
        if((s==0 || arr[s-1]<x) && arr[s]==x)
            return s;
        else if(arr[s]<x)
            l = s + 1;
        else
            d = s - 1;
    }
    if(l==n)
        return -2;
    if(d==-1)
        return -3;
    return d;
}

int fnd_last(int arr[], int n, int x)
{

    int l = 0, d = n-1;
    while(l<=d)
    {
        int s = l + (d-l)/2;
        if((s==n-1 || arr[s+1]>x) && arr[s]==x)
            return s;
        else if(arr[s]<x)
            l = s + 1;
        else
            d = s - 1;
    }
    if(l==n)
        return -2;
    if(d==-1)
        return -3;

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

    int n, q;cin>>n>>q;
    int p_med = n/2;
    int arr[n];
    for(int i = 0; i<n; cin>>arr[i++]);
    sort(arr, arr+n);

    while(q--)
    {
        int x;cin>>x;

        int first_p = fnd_first(arr, n, x);
        int last_p = fnd_last(arr, n, x);

        if(arr[first_p]==x && p_med>=first_p && p_med<=last_p)
        {
            cout<<"0\n";
        }else if(first_p == -3)
        {
            cout<<n+1<<"\n";
        }else if(last_p==-2)
        {
            cout<<n<<"\n";
        }else if(arr[first_p]!=x)
        {
            cout<<abs(first_p + 1 - n + first_p)+1<<"\n";
        }else
        {
            if(last_p==0)
            {
                cout<<n-1<<"\n";
            }else
            {
                cout<<min(abs(n-last_p-1 - last_p + 1), abs(n-1-last_p-last_p))<<"\n";
            }
        }
    }


    return 0;
}