/**
 *    author:  wxhtzdy
 *    created: 19.11.2022 12:10:19
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);  
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  map<int, bool> have; 
  map<int, int> fir;
  map<int, int> lst;
  for (int i = 0; i < n; i++) {
    have[a[i]] = true;
    if (!fir.count(a[i])) {
      fir[a[i]] = i;
    } 
    lst[a[i]] = i;
  }
  int x = a[n / 2];
  while (q--) {
    int b;
    cin >> b;
    if (x == b) {
      cout << 0 << '\n';
      continue;
    }
    if (!have[b]) {
      int pos = lower_bound(a.begin(), a.end(), b) - a.begin();
      if (b < x) {
        // 2 * pos + l == n + 1
        int l = n + 1 - 2 * pos;
        while (l > 0 && (pos + (l - 1)) == (n + l) / 2) {
          l--;          
        }
        while ((pos + l) != (n + l + 1) / 2) {
          l++;          
        }
        cout << l + 1 << '\n';
      } else {
        // 2 * pos == n + 1 + l
        int l = 2 * pos - (n + 1);
        while (l > 0 && pos == (n + (l - 1) + 1) / 2) {
          l--;  
        }
        while (pos != (n + l + 1) / 2) {
          l++;
        }
        cout << l + 1 << '\n'; 
      }
    } else {
      int pos;
      if (b < x) {              
        pos = lst[b];
      } else {
        pos = fir[b];        
      }
      if (b < x) {
        // 2 * pos + l == n
        int l = n - 2 * pos;
        while (l > 0 && (pos + (l - 1)) == (n + l - 1) / 2) {
          l--;          
        }
        while ((pos + l) != (n + l) / 2) {
          l++;          
        }
        cout << l << '\n';
      } else {
        // 2 * pos == n + l
        int l = 2 * pos - n;
        while (l > 0 && pos == (n + (l - 1)) / 2) {
          l--;  
        }
        while (pos != (n + l) / 2) {
          l++;
        }
        cout << l << '\n'; 
      }
    }   
  }                                                                  
  return 0;
}