#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, q; cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    while (q--) {
        int x; cin >> x;
        if (x < a[0] || x > a[n - 1]) {
            cout << n + (x < a[0]) << endl;
            continue;
        }
        int l = 0, r = n - 1, f = 0;
        while (l <= r) {
            int m = (l + r) / 2;
            if (a[m] <= x) {
                f = m; l = m + 1;
                continue;
            }
            r = m - 1;
        }
        if (a[f] != x) {
            if (f + 1 >= n - 1 - f) {
                cout << max(1, f + 1 - (n - 1 - f)) << endl;
                continue;
            }
            cout << n - 1 - f - f << endl;
            continue;
        }
        if (f < n / 2) {
            cout << n - 1 - f - f << endl;
            continue;
        }
        int g = f; l = 0; r = f;
        while (l <= r) {
            int m = (l + r) / 2;
            if (a[x] == m) {
                g = m; r = m - 1;
                continue;
            }
            l = m + 1;
        }
        if (g > n / 2) {
            cout << g - (n - g) << endl;
            continue;
        }
        cout << 0 << endl;
    }
}