#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int n, q, dal = 0;
	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++)
	{
		int j = 0;
		for (; j < n; j++)
		{
			if (komb[i] == pap[j])
			{
				dal = 1;
				break;
			}
		}
		cout << "J je" << j << endl;
		if ( n % 2 == 1)
		{
			if (j == 0 || j == n - 1)
		{
			cout << n - 1 << endl;		
		} else if (j == n)
		{
			cout << n << endl;
		} else
		{
			cout << abs(n / 2 + 1 - (n - j)) << endl;
		}
		} else
		{
			if ( j == n - 1 || j == 0)
		{
			if (j > n / 2)
			{
				cout << n - 2 << endl;
					} else
					{
						cout << n - 1 << endl;
							}		
		} else if (j == n)
		{
			cout << n << endl;
		} else
		{
			cout << abs(n / 2 - (n - j)) << endl;
		}
		}
		dal = 0;
	}
}