#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T>& operator--(vector<T>& v) {
  for (auto& i : v) --i;
  return v;
}
template <typename T>
vector<T>& operator++(vector<T>& v) {
  for (auto& i : v) ++i;
  return v;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& i : v) is >> i;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& i : v) os << i << ' ';
  return os;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <typename T, typename U>
pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
template <typename T, typename U>
pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
template <typename T, typename U>
void umin(T& a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
void umax(T& a, U b) {
  if (a < b) a = b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  int q;
  cin >> q;
  while (q--) {
    long long x;
    cin >> x;
    if (x % 2 == 1) {
      cout << x / 2 + 1 << '\n';
      continue;
    }
    long long ans = -1;
    for (int k = 0; (1ll << k) < n * 2 + 5; ++k) {
      if ((x - n * 2) & ((1ll << k) - 1)) continue;
      __int128 r = (__int128)n * 2 * ((1ll << k) - 1) + x;
      __int128 l = (1ll << k);
      if (r % l != 0) continue;
      __int128 i = r / l;
      if (i % 2 == 0) continue;
      if (i <= 0 || i >= n * 2) continue;
      ans = i / 2 + 1;
    }
    cout << ans << '\n';
  }
  return 0;
}
