#include <bits/stdc++.h>
using namespace std;
double get_sum(int x, int y) { return (1.0 * x + y) / 2; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, i, j;
  cin >> n;
  vector<int> ar(n);
  for (i = 0; i < n; i++) cin >> ar[i];
  double dp[n][n];
  for (i = 0; i < n; i++) dp[i][i] = ar[i];
  for (i = n - 2; i >= 0; i--) {
    for (j = i + 1; j < n; j++)
      dp[i][j] =
          max(get_sum(ar[j], dp[i][j - 1]), get_sum(ar[i], dp[i + 1][j]));
  }
  cout << dp[0][n - 1] << '\n';
  return 0;
}
