#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const int mod = 1000000007;
const int MAXN = 1010;
long long n, k, ans, a, b, q;
long double p;
long long dp[MAXN];
long double prob[10000][MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> k >> q;
  prob[0][0] = 1;
  for (int i = 1; i < 10000; i++) {
    for (int j = 1; j <= k; j++) {
      prob[i][j] =
          (long double)(prob[i - 1][j] * j + prob[i - 1][j - 1] * (k - j + 1)) /
          k;
    }
  }
  for (int i = 0; i < q; i++) {
    cin >> p;
    for (int i = 1; i <= 10000; i++) {
      if (p - eps <= prob[i][k] * 2000) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}
