using System;

namespace Takmicenje
{
    class Program
    {
        static int indeks(int pos, List<int> a, int b, int n)
        {
            int minDist = n;
            int minIndex = -1;
            for(int i= 0; i < n; i++)
            {
                if(a[i] == b)
                {
                    if(Math.Abs(pos - i) < minDist)
                    {
                        minDist = Math.Abs(pos - i);
                        minIndex = i;
                    }
                }
            }
            return minIndex;
        }
        static void Main(string[] args)
        {
            
            string[] st = Console.ReadLine().Split();
            int n = int.Parse(st[0]);
            int q = int.Parse(st[1]);
            List<int> a = new List<int>();
            int[] b = new int[q];
            int[] c = new int[q];
            st = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a.Add(int.Parse(st[i]));
            }
            a.Sort();
            int pos = n / 2;
            int median = a[pos];
            st = Console.ReadLine().Split();
            for (int i = 0; i < q; i++)
            {
                int index = indeks(pos, a, b[i] = int.Parse(st[i]), n);
                if (index == -1)
                {
                    int newIndex = n;
                    for (int j = 0; j < n; j++)
                    {
                        if (a[j] > b[i])
                        {
                            newIndex = j;
                            break;
                        }
                    }
                    a.Insert(newIndex, b[i]);
        
                    int levo = newIndex;
                    int desno = n - newIndex;
                    int help = Math.Abs(levo - desno);
                    c[i] = help + 1;
                    if (newIndex > pos) c[i]--;
                    a.Remove(b[i]);
                }
                else
                {
                    if (index == pos) c[i] = 0;
                    else
                    {
                        int levo = index;
                        int desno = n - index - 1;
                        if (levo == 0) c[i] = desno;
                        else if (desno == 0) c[i] = levo - 1;
                        else
                        {
                            int help = Math.Abs(levo - desno);
                            if (index < pos) c[i] = help;
                            else c[i] = help - 1 + help % 2;
                        }
                    }
                }
            }
            for (int i = 0; i < q; i++)
            {
                Console.WriteLine(c[i]);
            }
        }
    }
}