#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll LLINF{1001002003004005006};
int main() {
  int N;
  cin >> N;
  vector<ull> value(N);
  for (int i = 0; i < (N); ++i) cin >> value[i];
  vector<vector<double>> dp(N, vector<double>(N, 0));
  for (int l = (N)-1; l >= 0; --l)
    for (int r = l; r < N; ++r) {
      if (l == r - 1)
        dp[l][r] = (value[l] + value[r]) / 2.0;
      else {
        for (int k = l; k < r; ++k) {
          dp[l][r] = std::max(dp[l][r], (dp[l][k] + dp[k + 1][r]) / 2.0);
        }
      }
    }
  std::cout << dp[0][N - 1] << '\n';
}
