#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define sz(x) (int)x.size()
#define f first
#define s second
#define mod 1000000007
// const int mod = 998244353;
// OVERFLOW!!!!!!!!!!!!!!!!!!

int main()
{
   ios_base::sync_with_stdio(false);
   cout.tie(nullptr);
   cin.tie(nullptr);
   int n, q;
   cin >> n >> q;
   int a[n];
   for (int i = 0; i < n; i++)
      cin >> a[i];
   sort(a, a + n);
   map<int, pair<int, int>> m;
   for (int i = n - 1; i >= 0; i--)
      m[a[i]].f = i + 1;
   for (int i = 0; i < n; i++)
      m[a[i]].s = i + 1;
   while (q--)
   {
      int x;
      cin >> x;
      int sredina = n / 2 + 1;
      if (m.find(x) != m.end())
      {
         // postoji
         if (m[x].f <= sredina && m[x].s >= sredina)
            cout << "0\n";
         else if (m[x].f >= sredina)
            cout << max(0, 2 * m[x].f - 2 - n) << "\n";
         else
            cout << max(0, 2 * (n - m[x].s) + 1 - n) << "\n";
      }
      else
      { // ne postoji
         int l = 0, r = n - 1, idx = n + 1;
         while (l <= r)
         {
            int mid = l + (r - l) / 2;
            if (a[mid] > x)
            {
               idx = mid + 1;
               r = mid - 1;
            }
            else
               l = mid + 1;
         }
         if ((n + 1) / 2 < idx)
            cout << max(1, max(2 * (n - idx + 1), 2 * (idx - 1)) - n) << "\n";
         else
            cout << max(1, max(2 * (n - idx + 1), 2 * (idx - 1)) - n + 1) << "\n";
      }
   }
   return 0;
}