#include<stdio.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define N 10000005
using namespace std;

int n, q;
int a[20001];
int len;

void solve(int x) {
	int l, r, m;
	l = lower_bound(a, a + n, x) - a;
	r = upper_bound(a, a + n, x) - a - 1;
	m = len/2 + 1;
	if (x == a[m]) {
		cout << 0 << "\n"; return;
	}
	else if (x < a[0]) {
		cout << len + 1 << "\n";
	}
	else if (x == a[0] && x != a[1]) {
		cout << len - 1 << "\n";
	}
	else if (x < a[m]) {
		cout << len - 2 * r - 1 << "\n"; return;
	}
	else if (x == a[len - 1]) {
		cout << len - 2 << "\n";
	}
	else if (x < a[len - 1]) {
		cout << 2 * l - len << "\n";
	}
	else {
		cout << len - 1 << "\n";
	}
}

//01234567890
//12345678901
//    rl

// 1 3 3 3 4 5
// 
// 0 3 4 5 6 7

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	len = n;

	sort(a, a + n);
	int qq[20001];

	for (int i = 0; i < q; i++) {
		cin >> qq[i];
	}
	for (int i = 0; i < q; i++) {
		solve(qq[i]);
	}
}