Problem: Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:

  1. choose an index of the sequence element i (1 ≤ i ≤ |a|); 
  2. consecutively perform assignments: <image>. 



Let's use function g(a, x) to represent the largest value that can be obtained from variable x, using the described operation any number of times and sequence a.

Sereja has sequence b1, b2, ..., b|b|. Help Sereja calculate sum: <image>. Record [bi, bi + 1, ..., bj] represents a sequence containing the elements in brackets in the given order. To avoid problems with precision, please, print the required sum divided by |b|2.

Input

The first line contains integer |b| (1 ≤ |b| ≤ 3·105) — the length of sequence b. The second line contains |b| integers b1, b2, ..., b|b| (1 ≤ bi ≤ 105).

Output

In a single line print a real number — the required sum divided by |b|2. Your answer will be considered correct if its absolute or relative error won't exceed 10 - 6.

Examples

Input

5
1 2 3 4 1


Output

1.238750000000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
using namespace std;
template <typename T1, typename T2>
inline void mine(T1 &x, T2 y) {
  if (x > y) x = y;
}
template <typename T1, typename T2>
inline void maxe(T1 &x, T2 y) {
  if (x < y) x = y;
}
ostream &operator<<(ostream &a, const vector<int> &b) {
  for (auto k : b) cout << k << ' ';
  return a;
}
const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 300010;
const double EPS = 1e-9;
const int D = 25;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> lm[MX];
vector<int> rm[MX];
int a[MX];
int rest[MX];
struct cmp {
  bool operator()(int x, int y) const {
    return a[x] < a[y] || (a[x] == a[y] && x < y);
  }
};
long double pw[3 * D];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pw[0] = 1;
  for (int i = 1; i < 3 * D; i++) pw[i] = pw[i - 1] / (long double)2;
  int n;
  cin >> n;
  set<int, cmp> st;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    auto it = st.begin();
    while (it != st.end() && a[*it] < a[i]) {
      --rest[*it];
      rm[*it].push_back(i);
      if (rest[*it] == 0)
        it = st.erase(it);
      else
        ++it;
    }
    rest[i] = D - 1;
    st.insert(i);
    rm[i] = {i};
  }
  st.clear();
  for (int i = n - 1; i >= 0; i--) {
    auto it = st.begin();
    while (it != st.end() && a[*it] <= a[i]) {
      --rest[*it];
      lm[*it].push_back(i);
      if (rest[*it] == 0)
        it = st.erase(it);
      else
        ++it;
    }
    rest[i] = D - 1;
    st.insert(i);
    lm[i] = {i};
  }
  long double ans = 0;
  for (int i = 0; i < n; i++) {
    if ((int)lm[i].size() != D) lm[i].push_back(-1);
    reverse(lm[i].begin(), lm[i].end());
    if ((int)rm[i].size() != D) rm[i].push_back(n);
    for (int l = 1; l < (int)lm[i].size(); ++l) {
      for (int r = 0; r < (int)rm[i].size() - 1; ++r) {
        int cnt = (int)lm[i].size() - l + r;
        long long len =
            1ll * (lm[i][l] - lm[i][l - 1]) * (rm[i][r + 1] - rm[i][r]);
        ans += pw[cnt] * (long double)len * (long double)a[i];
      }
    }
  }
  cout << setprecision(15) << fixed;
  cout << ans / (1ll * n * n) << '\n';
}