#include <bits/stdc++.h>

using namespace std;

#define ll long long

bool compare_pair( const pair<ll,ll> &pair1, const pair<ll,ll> &pair2)
{
    ll result = 0;
    if(pair2.first > pair1.first)
    {
        result = 1;
    }
    return result;
}

ll manji(ll a, ll b) {
    if(a == -1) return b;
    if(b == -1) return a;

    return min(a, b);
}

int main()
{
    ll n, q;
    cin >> n >> q;

    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];

    pair<ll, ll> b[q];
    ll r[q];
    ll temp;
    for(ll i = 0; i < q; i++){
        cin >> temp;
        b[i] = make_pair(temp, i);
        r[i] = -1;
    }

    sort(a, a+n);
    sort(b, b+q, &compare_pair);

    temp = 0;

    while(b[temp].first < a[0]) {
        r[b[temp].second] = n + 1;
        temp++;
    }
    ll tempr;
    for(ll i = 0; i < n; i++)  {

        if(temp == q) break;

        if(b[temp].first == a[i]) {
            tempr = n - 1 - 2 * min(i, n - 1 - i);
            if(n - 1 - i < i) {
                tempr -= 1;
            }
            r[b[temp].second] = manji(tempr, r[b[temp].second]);
        }

        while(temp < q && i < n-1 && b[temp].first < a[i+1]) {
            if(temp > 0 && b[temp].first == b[temp-1].first) {
                r[b[temp].second] = r[b[temp-1].second];
            }
            else if(b[temp].first == a[i]) {
            }
            else {
                tempr = n + 1 - 2 * (n-1-i < i+1 ? n-i-2 : i+1);
                r[b[temp].second] = n + 1 - 2 * min(i + 1, n - 1 - i);
                if(n - 1 - i < i + 1) {
                    r[b[temp].second] -= 1;
                }
            }

            temp++;
        }
    }
    for(ll i = temp; i <  q; i++) {
        r[b[i].second] = manji(r[b[i].second], n);
    }

    for(ll i = 0; i < q; i++)
        cout << r[i] << endl;


    return 0;
}