#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <iterator>

using namespace std;

#define FOR(i, a, b) for(int i=a; i<b; i++)

void unos(vector<int>& arr, int n) {
    FOR(i, 0, n) scanf("%d", &arr[i]);
}

int main(void) {

    ios_base::sync_with_stdio(0); cin.tie(0);


    int n, q;

    scanf("%d%d", &n, &q);

    vector<int> a(n), b(q);

    unos(a, n); unos(b, q);

    sort(a.begin(), a.end(), less<int>());

    FOR(i, 0, q) {
        auto ele = lower_bound(a.begin(), a.end(), b[i]);

        int l, d;
        if(ele == a.end() || *ele != b[i]) {
            if( b[i] > a[a.size()-1] ) {
                cout << n << "\n";
            } else {
                cout << n + 1 << "\n";
            }

        } else {
            auto ub = upper_bound(a.begin(), a.end(), b[i]);
            int min = INT32_MAX;
            for(; ele != ub; ele++){
                l = distance(a.begin(), ele);
                d = n - l - 1;

                if( l > d ) {
                    /* cout << l - d - 1 << "\n"; */
                    min = std::min(min, l - d - 1);
                } else {
                    /* cout << abs(l - d) << "\n"; */
                    min = std::min(min, abs( l - d ));
                }
            }
            cout << min << "\n";
        }
    }


    return 0;
}