#include <bits/stdc++.h>

using namespace std;

void ispisiNiz(int n, long int niz[]) {
	for (int i = 0; i < n; ++i)
		cout << niz[i] << " ";
	cout << endl;
}

int binarna_nema(vector<long> v, int n, long int x) {
	int low = 0, high = n-1;
	while (high - low > 1) {
		int mid = (low + high)/2;
		if (v.at(mid) < x) 
			low = mid;
		else
			high = mid;
	}
	long gore = v.at(high), dole = v.at(low);
	if (x < gore && x > dole)
		return low;
	if (x > gore)
		return high;
	return low;
}

int main()
{	
	int n, q;
	long int a[200001], b[200001];
	cin >> n >> q;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < q; ++i)
		cin >> b[i];

	vector<long> v(a, a+n);
	sort(v.begin(), v.end());

	int levoX, desnoX;
	int levo, desno, operacije;
	int iX;
	vector<long>::iterator lower, upper;
	for (int i = 0; i < q; ++i)
	{
		if (v.at(n/2) == b[i]) {
			cout << 0 << endl;
			continue;
		}
		if (binary_search(v.begin(), v.end(), b[i])) {
			lower = lower_bound(v.begin(), v.end(), b[i]);
			upper = upper_bound(v.begin(), v.end(), b[i]);
			levoX = lower - v.begin();
			desnoX = upper - v.begin();
			if (levoX > n/2) {
				iX = levoX;
			}
			else {
				iX = desnoX;
			}

			levo = iX;
			desno = n-1-levo;
			operacije = 0;
		}
		else {
			int iX = binarna_nema(v, n, b[i]);
			iX++;

			levo = iX;
			desno = n-levo;
			operacije = 1;
		}
		if (levo > desno) {
			cout << levo - desno - 1 + operacije << endl;
		}
		else {
			cout << desno - levo + operacije << endl;
		}
	}

	return 0;
}