#include <bits/stdc++.h>

using namespace std;
int bs(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return bs(arr, l, mid - 1, x);
        return bs(arr, mid + 1, r, x);
    }
    return l;
}
int main()
{
    int n, q;
    cin >> n >> q;
    int a[n];
    for (int i = 0; i < n; i++)
    cin >> a[i];
    for (int i = 0; i < q; i++)
    {
        int pom;
        cin >> pom;
        int ix = bs(a, 0, n - 1, pom);
        if (a[ix] == pom)
        {
            if (ix == n / 2)
            {
                cout << 0 << '\n';
            }
            else if (ix > n / 2)
            {
                while (a[ix] == pom)
                ix--;
                ix++;
                cout << 2 * ix - n << '\n';
            }
            else
            {
                while (a[ix] == pom)
                ix++;
                ix--;
                cout << n - 1 - 2 * ix << '\n';
            }
        }
        else
        {
            if (ix > n / 2)
            {
                cout << 2 * ix - n << '\n';
            }
            else
            {
                cout << n - 2 * ix + 1 << '\n';
            }
        }
    }
    return 0;
}