#include <bits/stdc++.h>
using namespace std;
using lld = int64_t;
using llf = long double;
const int N = 1000000 + 5;
int a[N], q[N];
int l[N], r[N];
lld sm[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(15);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) cin >> q[i];
  {
    stack<int, vector<int> > stk;
    stk.push(0);
    for (int i = 1; i <= n; ++i) {
      while (a[stk.top()] >= a[i]) stk.pop();
      l[i] = stk.top();
      stk.push(i);
    }
  }
  {
    stack<int, vector<int> > stk;
    stk.push(n + 1);
    for (int i = n; i >= 1; --i) {
      while (a[stk.top()] > a[i]) stk.pop();
      r[i] = stk.top();
      stk.push(i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    sm[1] += a[i];
    sm[i - l[i] + 1] -= a[i];
    sm[r[i] - i + 1] -= a[i];
    sm[r[i] - l[i] + 1] += a[i];
  }
  for (int i = 1; i <= n; ++i) sm[i] += sm[i - 1];
  for (int i = 1; i <= n; ++i) sm[i] += sm[i - 1];
  for (int i = 0; i < m; ++i)
    cout << fixed << (static_cast<llf>(sm[q[i]]) / (n - q[i] + 1)) << '\n';
  return 0;
}
