using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_Namestanje_glasanja
{
    class Program
    {
        static int BrManjih(int[] a, int k)
        {
            int l = 0;
            int d = a.Length;
            while (l < d)
            {
                int s = l + (d - l) / 2;
                if (a[s] < k)
                    l = s + 1;
                else
                    d = s;
            }
            return d;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int q = int.Parse(s[1]);
            int[] a = new int[n];
            s = Console.ReadLine().Split();
            Dictionary<int, int> d = new Dictionary<int, int>();
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s[i]);
                if (d.ContainsKey(a[i]))
                    d[a[i]]++;
                else
                    d.Add(a[i], 1);
            }
            Array.Sort(a);
            s = Console.ReadLine().Split();
            for (int i = 0; i < q; i++)
            {
                int b = int.Parse(s[i]);
                int m = BrManjih(a, b);
                if (d.ContainsKey(b))
                {
                    int min = int.MaxValue;
                    for (int j = 0; j < d[b]; j++)
                    {
                        m += j;
                        int v = n - m-1;
                        int k;
                        if (v < m)
                            k = m - v-1;
                        else if (m < v)
                            k = v - m;
                        else
                            k = 0;
                        min = Math.Min(min, k);
                    }
                    Console.WriteLine(min);
                }
                else
                {
                    int v = n - m;
                    if (v < m)
                        Console.WriteLine(m-v);
                    else if (m < v)
                        Console.WriteLine(v-m+1);
                    else
                        Console.WriteLine(1);
                }
            }
        }
    }
}