#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
double dp[10 * 1005][1005];
int ans[1005];
int main() {
  int k, q;
  scanf("%d%d", &k, &q);
  dp[0][0] = 1;
  for (int i = 1;; i++) {
    dp[i][0] = 0;
    for (int j = 1; j <= k; j++) {
      dp[i][j] = dp[i - 1][j - 1] * ((k - j + 1.0) / k) + dp[i - 1][j] * j / k;
    }
    if (dp[i][k] * 2 >= 1) break;
  }
  int pos = 1;
  for (int i = 1; i <= 1000; i++) {
    while (dp[pos][k] * 2000 < i) pos++;
    ans[i] = pos;
  }
  while (q--) {
    int p;
    scanf("%d", &p);
    printf("%d\n", ans[p]);
  }
}
