#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip> 
#include <map>
#include <string>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <iterator>

#define f(n) for (long long i = 0; i < n; i++)
#define f0(n) for (int j = 0; j < n; j++)
#define co(n) cout << n << "\n";

using namespace std;

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

    long long n, q;
    cin >> n >> q;
    vector<int> a(n);
    vector<int> b(q);
    f(n) cin >> a[i];
    f(q) cin >> b[i];
    sort(a.begin(), a.end());
    f(q)
    {
        long long r = 0;
        int x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        long long v = a.size();
        if (a[min(x, (int)a.size() - 1)] != b[i])
        {
            v++;
            r++;
        }
        long long s = v / 2;
        r += 2 * abs(x - s);
        if (v % 2 != 0 && x - s > 0 || v % 2 == 0 && x - s < 0) r--;
        co(r);
    }
}