#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int arr[maxn], arr1[maxn];
int n, k, x;
set<int> candMin, candMax;
void perform() {
  sort(arr + 1, arr + n + 1);
  candMin.insert(arr[1]);
  candMax.insert(arr[n]);
  for (int i = 1; i <= n; i += 2) arr[i] ^= x;
}
void perform1() {
  sort(arr1 + 1, arr1 + n + 1);
  for (int i = 1; i <= n; i += 2) arr1[i] ^= x;
}
double p[1010][10010];
double ptree[1010];
double eps = 1e-7;
int main() {
  int k, q;
  cin >> k >> q;
  p[0][0] = 1.0;
  int days = 8000;
  for (int i = 1; i <= k; i++) ptree[i] = (1.0 * i) / k;
  for (int day = 1; day <= days; day++)
    for (int trees = 1; trees <= k; trees++) {
      p[trees][day] = ptree[trees] * p[trees][day - 1] +
                      ptree[k - trees + 1] * p[trees - 1][day - 1];
    }
  while (q--) {
    double pr;
    cin >> pr;
    double prob = (pr - eps) / 2000.0;
    for (int i = 1; i <= days; i++)
      if (p[k][i] > prob) {
        printf("%d\n", i);
        break;
      }
  }
  return 0;
}
