#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector <string> vs;
const int inf = 1e9 + 5;
#define FAST ios::sync_with_stdio(false); cin.tie(0);
#define MAX INT_MAX
#define MIN INT_MIN
#define potato 0
#define lomljenje break

/*
#define A first
#define B second
#define PB push_back
#define MP make_pair
*/

int main()
{
    FAST

    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    for(int i = 0; i < k; ++i)
    {
        int x;
        cin >> x;
        int l = 0, r = n - 1;
        while(l <= r)
        {
            int p = (l + r) / 2;
            if(a[p] <= x) l = p + 1;
            else r = p - 1;
        }
        int med = n / 2;
        if(r < med) while(a[r + 1] == x && r + 1 < n) ++r;
        else while(a[r - 1] == x && r - 1 >= 0) --r;
        int br = 0, q = n;
        if(a[r] != x)
        {
            ++r;
            ++q;
            ++br;
        }
        ///cout << "r: " << r << ", med: " << med << ", k: " << q << endl;

        int novi_br = abs(r - q / 2) * 2;
        br += novi_br;
        bool paran = false;
        bool neparan = false;
        if(q % 2 != 1) paran = true;
        if(q % 2 == 1) neparan = true;
        if(paran)
        {
            if(r < med) br -= 1;
        }
        if(neparan)
        {
            if(r > med) br -= 1;
        }
        cout << br << endl;
    }
    return potato;
}