#include <bits/stdc++.h>
using namespace std;
const int N = 1000012, INF = 2147483647;
int n, m, a[N], z[N], top, l[N], r[N], k;
long long d1[N], d2[N], sum1 = 0, sum2 = 0;
double ans[N];
int main() {
  memset(d1, 0, sizeof(d1));
  memset(d2, 0, sizeof(d2));
  scanf("%d", &n);
  a[0] = a[n + 1] = -INF;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  z[top = 0] = 0;
  for (int i = 1; i <= n; ++i) {
    while (a[z[top]] > a[i]) --top;
    l[i] = i - z[top];
    z[++top] = i;
  }
  z[top = 0] = n + 1;
  for (int i = n; i; --i) {
    while (a[z[top]] >= a[i]) --top;
    r[i] = z[top] - i;
    z[++top] = i;
  }
  for (int i = 1; i <= n; ++i) {
    if (l[i] > r[i]) swap(l[i], r[i]);
    d2[1] += a[i];
    d2[l[i] + 1] -= a[i];
    d1[l[i] + 1] += (long long)l[i] * a[i];
    d1[r[i] + 1] -= (long long)l[i] * a[i];
    d2[r[i] + 1] -= a[i];
    d2[l[i] + r[i]] += a[i];
    d1[r[i] + 1] += (long long)(l[i] + r[i]) * a[i];
    d1[l[i] + r[i]] -= (long long)(l[i] + r[i]) * a[i];
  }
  for (int i = 1; i <= n; ++i) {
    sum1 += d1[i];
    sum2 += d2[i];
    ans[i] = (sum1 + sum2 * i) * 1.0 / (n - i + 1);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) scanf("%d", &k), printf("%.10lf\n", ans[k]);
}
