#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, s = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') s = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + (c ^ '0');
    c = getchar();
  }
  return x * s;
}
long long n, m, r[1000010], l[1000010], a[1000010];
long long k, x, y, C1, C2;
long long s1[1000010], s2[1000010];
double ans[1000010];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  a[n + 1] = (long long)(-(1 << 60));
  a[0] = (long long)(-(1 << 60));
  for (int i = n; i; i--) {
    if (a[i + 1] <= a[i])
      r[i] = i + 1;
    else
      for (int j = r[i + 1]; j <= n + 1; j = r[j])
        if (a[j] <= a[i]) {
          r[i] = j;
          break;
        }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] < a[i])
      l[i] = i - 1;
    else
      for (int j = l[i - 1]; j >= 0; j = l[j])
        if (a[j] < a[i]) {
          l[i] = j;
          break;
        }
  }
  for (int i = 1; i <= n; i++) {
    l[i] = i - l[i];
    r[i] = r[i] - i;
  }
  for (int i = 1; i <= n; i++) {
    int x = l[i], y = r[i];
    if (x > y) swap(x, y);
    s1[1] += a[i];
    s1[x + 1] -= a[i];
    s2[x + 1] += a[i] * x;
    s2[y + 1] -= a[i] * x;
    s2[y + 1] += a[i] * (x + y);
    s2[x + y] -= a[i] * (x + y);
    s1[y + 1] -= a[i];
    s1[x + y] += a[i];
  }
  for (int i = 1; i <= n; i++) {
    C1 += s1[i], C2 += s2[i];
    ans[i] = ((C1 * i + C2) * 1.00) / ((n - i + 1) * 1.00);
  }
  m = read();
  while (m--) {
    long long k = read();
    printf("%.9lf\n", ans[k]);
  }
  return 0;
}
