#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
const long long INF = (1ll << 60);
long long n, a[N + 5], m, l[N + 5], r[N + 5];
long long s1[N + 5], s2[N + 5];
double ans[N + 5];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  l[0] = r[n + 1] = -INF;
  for (int i = n; i >= 1; i--)
    if (a[i] >= a[i + 1])
      r[i] = i + 1;
    else
      for (int j = r[i + 1]; j <= n + 1; j = r[j])
        if (a[i] >= a[j]) {
          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++) {
    int x = i - l[i], y = r[i] - i;
    if (x > y) swap(x, y);
    s1[1] += a[i], s1[x + 1] -= a[i];
    s2[x + 1] += x * a[i], s2[y + 1] -= x * a[i];
    s1[y + 1] -= a[i], s1[x + y] += a[i];
    s2[y + 1] += (x + y) * a[i], s2[x + y] -= (x + y) * a[i];
  }
  long long S1 = 0, S2 = 0;
  for (int i = 1; i <= n; i++) {
    S1 += s1[i];
    S2 += s2[i];
    ans[i] = 1.0 * (i * S1 + S2) / ((n - i + 1) * 1.0);
  }
  scanf("%lld", &m);
  while (m--) {
    int x;
    scanf("%d", &x);
    printf("%.9lf\n", ans[x]);
  }
  return 0;
}
