#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& cout, vector<T> V) {
  cout << "[ ";
  for (auto v : V) cout << v << ' ';
  return cout << ']';
}
template <class L, class R>
ostream& operator<<(ostream& cout, pair<L, R> P) {
  return cout << '(' << P.first << ',' << P.second << ')';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int q;
  cin >> q;
  vector<long double> ans(1);
  vector<long double> dp(n + 1);
  dp[n] = 1;
  while (ans.back() <= 0.5) {
    vector<long double> tdp(n + 1);
    for (long long int i = 0; i < (n + 1); i++) {
      if (i != n)
        tdp[i] = dp[i] * (n - i) / n + dp[i + 1] * (i + 1) / n;
      else
        tdp[i] = dp[i] * (n - i) / n;
    }
    ans.push_back(tdp[0]);
    dp = tdp;
  }
  while (q--) {
    long long int p;
    cin >> p;
    long double prob = (long double)p / 2000;
    long long int fans = -1;
    for (long long int i = 0; i < (ans.size()); i++) {
      if (ans[i] >= prob) {
        fans = i;
        break;
      }
    }
    assert(fans != -1);
    cout << fans << '\n';
  }
  cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC
       << "ms\n";
  ;
}
