#include <bits/stdc++.h>
using namespace std;
int n, q;
double dp[10005][1005], p;
int main() {
  scanf("%d%d", &n, &q);
  dp[0][0] = 1;
  for (int i = 1; i <= 10000; i++)
    for (int j = 1; j <= n; j++)
      dp[i][j] = dp[i - 1][j - 1] * (n - j + 1) / n + dp[i - 1][j] * j / n;
  while (q--) {
    scanf("%lf", &p);
    p /= 2000;
    for (int i = 1; i <= 10000; i++)
      if (dp[i][n] > p) {
        printf("%d\n", i);
        break;
      }
  }
  return 0;
}
