#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n, q;
    cin >> n >> q;
    long long a[n], b[q];
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < q; i++) cin >> b[i];
    sort (a, a + n);
    for (long long i = 0; i < q; i++)
    {
        if (b[i] > a[n - 1] || b[i] < a[0]) cout << n << endl;
        else if (n % 2 == 0)
        {
            if (b[i] == a[n / 2]) cout << 0 << endl;
            else if (b[i] < a[n / 2])
            {
                for (long long j = 1; j < n / 2; j++)
                {
                    bool t = false;
                    if (b[i] > a[n / 2 - j]) t = true;
                    if (a[n / 2 - j] == b[i] || t)
                    {
                        if (t) cout << 2 * (j - 1) + 1 << endl;
                        else cout << 2 * j - 1 << endl;
                        break;
                    }
                }
                continue;
            }
            else if (b[i] > a[n / 2])
            {
                for (long long j = 1; j < n / 2; j++)
                {
                    bool t = false;
                    if (b[i] < a[n / 2 + j]) t = true;
                    if (a[n / 2 + j] == b[i] || t)
                    {
                        if (t) cout << 2 * j << endl;
                        else cout << 2 * j - 1 << endl;
                        break;
                    }
                }
                continue;
            }
        }
        else if (n % 2 == 1)
        {
            if (b[i] == a[n / 2]) cout << 0 << endl;
            else if (b[i] < a[n / 2])
            {
                for (long long j = 1; j < n / 2 + 1; j++)
                {
                    bool t = false;
                    if (b[i] > a[n / 2 - j]) t = true;
                    if (a[n / 2 - j] == b[i])
                    {
                        if (t) cout << 2 * j - 1 << endl;
                        else cout << 2 * j << endl;
                        break;
                    }
                }
                continue;
            }
            else if (b[i] > a[n / 2])
            {
                for (long long j = 1; j < n / 2 + 1; j++)
                {
                    bool t = false;
                    if (b[i] > a[n / 2 + j]) t = true;
                    if (a[n / 2 + j] == b[i])
                    {
                        if (t) cout << 2 * j - 1 << endl;
                        else cout << 2 * j - 1 << endl;
                        break;
                    }
                }
                continue;
            }
        }
    }
    return 0;
}