#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int n, q;
	cin >> n >> q;
	int pap[n], komb[q];
	for (int i = 0; i < n; i++)
	{
		cin >> pap[i];
	}
	for (int i = 0; i < q; i++)
	{
		cin >> komb[i];
	}
	for (int i = 0; i < q; i++)
	{
		if (n % 2 == 0)
		{
			if (komb[i] == (pap[n/2] + pap[n / 2 + 1]) / 2 + 1)
			{
				cout << 0 << endl;
				continue;
			}
		} else
		{
			if (komb[i] == pap[n / 2])
			{
				cout << 0 << endl;
				continue;
			}
		}
		for (int j = 0; i < n; j++)
		{
			if (komb[i] == pap[j])
			{
			 	cout << abs((j - (n - 1 - j))) << endl;
				break;
			}
		}
	}
	
}