#include <bits/stdc++.h>
using namespace std;
const int MAXN = 8 * 1e3 + 200;
const int INF = int(1e9) + 7;
const long long LINF = 1ll * INF * INF;
const int md = int(1e9) + 7;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;
int k, q;
long double dp[MAXN][1001];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> k >> q;
  dp[0][0] = 1.0;
  for (int i = 0; i < 8000; i++) {
    for (int j = 0; j <= min(i, k); j++) {
      dp[i + 1][j] += dp[i][j] * j / k;
      dp[i + 1][j + 1] += dp[i][j] * (k - j) / k;
    }
  }
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    long double val = 1.0 * x / 2000;
    for (int day = 0; day < 8000; day++) {
      if (dp[day][k] >= val) {
        cout << day << endl;
        break;
      }
    }
  }
  return 0;
}
