#include <bits/stdc++.h>

using namespace std;

int a[200000];
int b[200000];

int calc(int n, int q, int x) {
	int mid = n / 2;
	if(a[mid] == x) return 0;
	int l = 0, d = n - 1;
	bool ima = false, levo = false;
	
	int i;
	if(a[mid] > x) {
		levo = true;
		d = mid - 1;
		while(l <= d) {
			int s = (l + d) / 2;
			if(a[s] <= x) {
				if(!ima && a[s] == x) ima = true; 
				l = s + 1;
			}
			else d = s - 1;
		}
		i = d;
	}
	else {
		l = mid + 1;	
		while(l <= d) {
			int s = (l + d) / 2;
			if(a[s] >= x) {
				if(!ima && a[s] == x) ima = true;
				d = s - 1;
			}
			else l = s + 1;
		}
		i = l;
	} 
	if(!ima) {
		if(levo) i++;
		n++;
	}
	
	l = i;
	d = n - i - 1;
	if(d < l && ((l - d) + n) % 2 != 0) return l - d - 1 + !ima;
	return abs(l - d) + !ima;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, q;
	cin>>n>>q;
	for(int i = 0; i < n; i++) cin>>a[i];
	for(int i = 0; i < q; i++) cin>>b[i];
	sort(a, a + n);
	for(int i = 0; i < q; i++) cout<<calc(n, q, b[i])<<endl;
	return 0;
}