#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9 + 10;
const long long MOD = 1e9 + 696969;
const long long INF = 1e18;
const double EPS = 1e-7;
double DP[10010][1010];
int n, k;
int zap;
int main() {
  cin >> k >> zap;
  DP[0][0] = 2000.0;
  for (int i = (1); i <= (10000); ++i) {
    for (int j = (1); j <= (k); ++j)
      DP[i][j] = DP[i - 1][j] * j / k + DP[i - 1][j - 1] * (k - j + 1) / k;
  }
  while (zap--) {
    double pi;
    cin >> pi;
    int wal = n;
    while (DP[wal][k] < pi + EPS) ++wal;
    cout << wal << endl;
  }
}
