using System;

namespace Zadatak_02_Namestanje_Glasova
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, q, i;
            string[] s = Console.ReadLine().Split();
            n = Convert.ToInt32(s[0]);
            q = Convert.ToInt32(s[1]);
            int[] a = new int[n];
            int[] b = new int[q];
            s = Console.ReadLine().Split();
            for (i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(s[i]);
            }
            s = Console.ReadLine().Split();
            for (i = 0; i < q; i++)
            {
                b[i] = Convert.ToInt32(s[i]);
            }
            Array.Sort(a);
            for (i = 0; i < q; i++)
            {
                if (a[n / 2] == b[i])
                {
                    Console.WriteLine(0);
                }
                else
                {
                    Console.WriteLine(Pretraga(a, b[i]));
                }
            }
            
        }


        static int Pretraga(int[] a, int b)
        {
            int i = a.Length / 2, x = -2, n = a.Length, e = 0;
            if (a[i] > b)
            {
                while (a[i] > b)
                {
                    i--;
                    if (a[i] == b)
                    {
                        x = i;
                    }
                    
                }
                if (x == -2)
                {
                    x = i + 1;
                    n++;
                    e++;
                    
                }
            }
            else
            {
                while(a[i] < b && i < n - 1)
                {
                    i++;
                    if (a[i] == b)
                    {
                        x = i;
                    }
                }
                if (x == -2)
                {
                    n++;
                    x = i + 1;
                    e++;
                }
            }
            e = e + Math.Abs(2*(x-(n/2)));
            if (x < n / 2 && n % 2 == 0)
            {
                e--;
            }
            else if(x > n / 2 && n % 2 == 1)
            {
                e--;
            }
            
            
            return e;
        }
    }
}