#include <algorithm>
#include <bits/stdc++.h>
#include <map>
#include <vector>
#define ll long long


using namespace std;

void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a;
    for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        a.push_back(x);
    }
    sort(a.begin(), a.end());
    std::map<ll, ll> map;
    for (ll i = 0; i < n; i++) {
        if (map.count(a[i])) {
            if (abs(i - (n/2)) < abs(map[a[i]] - (n/2)))
                map[a[i]] = i;
        }
        else 
            map[a[i]] = i;
    }
    //taking quires
    for (ll i = 0; i < q; i++) {
        ll x;
        cin >> x;
        ll ans = -1;
        //if number is in array
        if (map.count(x)) {
            ll index = map[x];
            ans = std::abs(index - (n-1-index));
            if (index > (n-1)/2)
                ans--;
        }
        else {
            ll firstOver = lower_bound(a.begin(), a.end(), x) - a.begin();
            if (firstOver == n) {
                ans = n;
            }
            else {
                ans = 1;
                ans += abs((n - firstOver) - firstOver);
                if (firstOver > n/2)
                    ans--;
            }
        }
        cout << ans << "\n";
    }
}


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}