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

int fnd_first(ll arr[], int n, ll x)
{
    int l = 0, d = n-1;
    while(l<=d)
    {
        //cout<<l<<" "<<d<<"\n";
        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;
    }

    //cout<<l<<" "<<d<<"kraj\n";;
    if(l==n)
        return -2;
    if(d==-1)
        return -3;
    return d;
}

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

    int l = 0, d = n-1;
    while(l<=d)
    {
        //cout<<l<<" "<<d<<"\n";
        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;
    }
    //cout<<l<<" "<<d<<"kraj\n";;
    if(l==n)
        return -2;
    if(d==-1)
        return -3;

    return d;
}

ll solve(ll arr[], int n)
{
    ll x;cin>>x;
    int p_med = n/2;
    int first_p = fnd_first(arr, n, x);
    int last_p = fnd_last(arr, n, x);

    //cout<<first_p<<" "<<last_p;

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


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

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

    while(q-->1)
    {
        cout<<solve(arr,n)<<"\n";
    }
    cout<<solve(arr, n);


    return 0;
}