#include <iostream>

using namespace std;

int main() {
    int N, Q;
    scanf("%d %d", &N, &Q);
    int array[N], query[Q], index, element, startIndex, endIndex, value, l, g, b, m = N / 2, a;
    for (int i = 0; i < N; ++i)
        scanf("%d", &array[i]);
    for (int i = 0; i < Q; ++i)
        scanf("%d", &query[i]);
    for (int i = 0; i < Q; ++i) {
        value = query[i];
        startIndex = 0, endIndex = N - 1;
        while (startIndex != endIndex) {
            index = (startIndex + endIndex) / 2, element = array[index];
            if (element > value)
                endIndex = index - 1;
            else if (element < value)
                startIndex = index + 1;
            else {
                startIndex = index;
                break;
            }
        }
        if (array[startIndex] != value) {
            printf("%d\n", N);
            continue;
        }
        b = startIndex;

        startIndex = b, endIndex = N - 1;
        if (array[endIndex] == value) {
            g = endIndex;
            goto lesser;
        }
        while (startIndex + 1 != endIndex) {
            index = (startIndex + endIndex) / 2, element = array[index];
            if (element > value)
                endIndex = index;
            else
                startIndex = index;
        }
        g = endIndex - 1;

        lesser:
        startIndex = 0, endIndex = b;
        if (array[0] == value) {
            l = 0;
            goto final;
        }
        while (startIndex + 1 != endIndex) {
            index = (startIndex + endIndex) / 2, element = array[index];
            if (element < value)
                startIndex = index;
            else
                endIndex = index;
        }
        l = startIndex + 1;

        final:
        if (l > m)
            a = l - m;
        else if (g < m)
            a = m - g;
        else
            a = 0;
        printf("%d\n", a);
    }
    return 0;
}