using System;
using System.Collections.Generic;

class Program
{
    public static void ucitaj(List<int> a, int n)
    {
        var s = Console.ReadLine().Split();

        for (int i = 0; i < n; i++)
            a.Add(int.Parse(s[i]));
    }

    public static int medijana(List<int> a, int b, int m)
    {
        if (a.LastIndexOf(b) == -1 && b > a[a.Count - 1])
            return a.Count;
        if (a.LastIndexOf(b) == -1 && b < a[0])
            return a.Count + 1;

        if (a.LastIndexOf(b) == -1)
        {
            a.Add(b);
            a.Sort();
            return medijana(a, b, a[a.Count / 2]) + 1;
        }

        else
        {
            if (b == m)
            {
                return 0;
            }

            else if (b > m)
            {
                return a.Count % 2 == 0 ? ((a.IndexOf(b) - a.Count / 2) * 2) : ((a.IndexOf(b) - a.Count / 2) * 2) - 1;
            }

            else
            {
                return a.Count % 2 == 0 ? ((a.Count / 2 - a.LastIndexOf(b)) * 2) - 1 : ((a.Count / 2 - a.LastIndexOf(b)) * 2);
            }
        }
    }

    static void Main()
    {
        var s = Console.ReadLine().Split();

        int n = int.Parse(s[0]);
        int q = int.Parse(s[1]);

        List<int> a = new List<int>();
        List<int> b = new List<int>();

        ucitaj(a, n);

        a.Sort();

        int m = a[n / 2];
        int brojElemenata = a.Count;

        s = Console.ReadLine().Split();

        for (int i = 0; i < q; i++)
        {
            b.Add(int.Parse(s[i]));

            Console.WriteLine(medijana(a, b[i], m));

            if (brojElemenata != a.Count)
            {
                a.Remove(b[i]);
            }
        }
    }
}

// Ovom kodu je doprineo Milos