#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#define all(x) x.begin(), x.end()
using namespace std;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(all(a));
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        int les = lower_bound(all(a), x) - a.begin(), mor = a.end() - upper_bound(all(a), x);
        int l = -1, r = n + 5;
        while (l + 1 < r) {
            int m = l + r >> 1;
            int vl = (n + m) / 2 + 1;
            if (les < vl and vl <= (n - mor) + m) {
                r = m;
            } else {
                l = m;
            }
            //cout << l << ' ' << r << '\n';
        }
        cout << r << '\n';
    }
}