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

using ll = long long;

void solve()
{
    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());

    int m = n / 2;

//    cout << "--- querries ---\n";

    while(q--) {
        int b; cin >> b;

        if (b == a[m]) {
            cout << 0 << "\n";
            continue;
        }

        int ind = lower_bound(a.begin(), a.end(), b) - a.begin();
 //       cout << "IND: " << ind << "\n";

        int add = 0;
        if (a[ind] != b) {
            ++n;

            m = n / 2;
            add = 1;
        }

        if (ind <= m) {
            cout << 2 * (m - ind) - (n%2 == 0) + add << "\n";
        }
        else {
            cout << 2 * (ind - m) - (n % 2) + add << "\n";
        }
    }
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();

    return 0;
}