#include <iostream>

using namespace std;

int provera(int a[], int x, int n)
{
    for(int i=0; i<n; ++i)
    {
        if(a[i] == x)
            return i+1;
    }
    return -1;
}

int pretraga(int a[], int x, int n)
{
    for(int i=0; i<n; ++i)
    {
        if(a[i]>x)
            return i+1;
    }
    return n+1;
}

int main()
{
    int n, q;
    cin >> n >> q;
    int a[n], b[q];
    int m = (n/2)+1;
    for(int i=0; i<n; ++i)
    {
        cin >> a[i];
    }
    for(int i=0; i<q; ++i)
    {
        cin >> b[i];
    }
    for(int i=0; i<q; ++i)
    {
        if(a[m-1] == b[i])
            cout << 0 << endl;
        else
        {
            int index = provera(a, b[i], n);
            if(index > -1)
            {
                if(index<m)
                    cout << (n-index)-(index-1) << endl;
                else
                    cout << (index-1)-(n-index+1) << endl;
            }
            else
            {
                index = pretraga(a, b[i], n);
                int mTemp = (n+1)/2+1;
                if(index<=mTemp)
                    cout << (n+1-index)-(index-1)+1 << endl;
                else
                {
                    if(index<=n)
                        cout << index-2 << endl;
                    else
                        cout << index-1 << endl;
                }
            }
        }
    }
}