#include <bits/stdc++.h>
using namespace std;
void fun() {}
long long int md = 1e9 + 7;
long long int __gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return __gcd(b, a % b);
}
long long int poww(long long int a, long long int b, long long int md) {
  if (b < 0) return 0;
  if (a == 0) return 0;
  long long int res = 1;
  while (b) {
    if (b & 1) {
      res = (1ll * res * a) % md;
    }
    a = (1ll * a * a) % md;
    b >>= 1;
  }
  return res;
}
void ainp(long long int arr[], long long int n) {
  for (long long int i = 1; i <= n; i++) cin >> arr[i];
}
long long int divide(long long int a, long long int b, long long int md) {
  long long int rr = a * (poww(b, md - 2, md));
  rr %= md;
  return rr;
}
long long int k, q;
long double ee = 1e-7;
long double dp[9001][1001];
set<pair<long double, long long int> > s;
long double solve(long long int days, long long int gems) {
  if (days < 0) return 0;
  if (days < gems) return dp[days][gems] = 0;
  if (gems == 0) return dp[days][gems] = 1;
  if (dp[days][gems] != -1) return dp[days][gems];
  long double ans =
      solve(days - 1, gems - 1) * gems + solve(days - 1, gems) * (k - gems);
  ans /= k;
  return dp[days][gems] = ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  fun();
  cin >> k >> q;
  for (long long int i = 0; i < 9001; i++)
    for (long long int j = 0; j < 1001; j++) dp[i][j] = -1;
  for (long long int i = 0; i <= 9000; i++)
    s.insert(make_pair(solve(i, k) * 2000 + ee, i));
  long long int pi;
  while (q--) {
    cin >> pi;
    cout << (s.lower_bound(make_pair(pi, 0))->second) << "\n";
  }
  return 0;
}
