#include <bits/stdc++.h>
using namespace std;
template <typename T, typename S>
inline bool REMIN(T &a, const S &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool REMAX(T &a, const S &b) {
  return a < b ? a = b, 1 : 0;
}
int toint(const string &s) {
  stringstream ss;
  ss << s;
  int x;
  ss >> x;
  return x;
}
string tostring(int number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
int bit(long long x, int pos) { return ((1ll << pos) & x) ? 1 : 0; }
const int INF = 1e9;
const int NMAX = 1e5 + 2;
const long long MOD = 1000000007;
const long double PI = 2 * acos(0);
int T, N, M, K, Q;
int a, b, c;
string s;
void nope(int dec = 0) {
  if (!dec) cout << "NO";
  exit(0);
}
int ans[1004];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> K >> Q;
  if (K == 1) {
    for (int(i) = int(1); (i) <= int(Q); ++(i)) cout << 1 << '\n';
    return 0;
  }
  vector<pair<int, int> > qs;
  for (int(i) = int(1); (i) <= int(Q); ++(i)) {
    cin >> a;
    qs.push_back({a, i});
  }
  sort(qs.begin(), qs.end());
  vector<long double> pas(K + 1, 0), cur(K + 1, 0);
  pas[1] = 1;
  int d = 2;
  while (!qs.empty()) {
    for (int(i) = int(1); (i) <= int(K); ++(i)) {
      cur[i] = pas[i] * i / K + pas[i - 1] * (K - (i - 1)) / K;
    }
    while (!qs.empty() && (*qs.begin()).first / 2000.0 <= cur[K]) {
      ans[(*qs.begin()).second] = d;
      qs.erase(qs.begin());
    }
    d++;
    pas = cur;
  }
  for (int(i) = int(1); (i) <= int(Q); ++(i)) cout << ans[i] << '\n';
  return 0;
}
