#include <iostream>
using namespace std;
//typedef long long int;
void bubble(int A[], int n)
{
    bool p = true;
    for (int gr = n - 1; gr > 0 && p; gr--)
    {
        p = false;
        for (int i = 0; i < gr; i++)
        {
            if (A[i] > A[i + 1])
            {
                p = true;
                int t = A[i];
                A[i] = A[i + 1];
                A[i + 1] = t;
            }
        }
     }
}
int Find(int A[], int N, int x)
{
    int l = -1, r = N, s;
    while (r-l >1)
    {
        s = (l+r) / 2;
        if (A[s] >= x) r = s;

        else if (A[s] <= x) l = s;
        else
            return r;
    }
    return r;
}
int  main()
{
    int N, Q;
    cin >> N >> Q;
    int A[200001], B[200001], R[200001];

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    bubble(A, N);
    int med = A[N / 2];
    int f;
    for (int i = 0; i < Q; i++)
    {
        cin >> B[i];
        if (B[i] == med)  R[i] = 0; 
        else
        {
            f = Find(A, N, B[i]);
           
            if (A[f] == B[i])
            {
                
                int l = f;
                int r = N - f - 1;
                
                if (r > l) R[i] = r-l;
                else { R[i] = l - r; if (N % 2 == 1) R[i]--; }
                
            }
            else
            {

                int l = f;
                int r = N - f - 1;

                if (r > l) { R[i] = r - l; if (N % 2 == 1) R[i]++;}
                
                else { R[i] = l - r; if (N % 2 == 1) R[i]--; }
                
            }
        }        
    }
    for (int i = 0; i < Q; i++)
    {
        cout << R[i]<<endl;
    }
    return 0;
}