10
-405 -230 252 -393 -390 -259 97 163 81 -129
 3
10000 -10000 10000
 1
-10000
 20
-16 -23 29 44 -40 -50 -41 34 -38 30 -12 28 -44 -49 15 50 -28 38 -2 0

702.333333333333712
 10000.000000000016371
 0.000000000000000
 113.875000000000043

#include <bits/stdc++.h>
using namespace std;
struct node {
  double data, wei;
} p[222222];
double hehe[222222], ans, maxx[222222], minn[222222], a;
int n, l, r, q[222222], tot;
bool cmp(node a, node b) { return a.data / a.wei < b.data / b.wei; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    scanf("%lf", &a), p[i].data = p[i - 1].data + a, p[i].wei = i;
  sort(p + 1, p + n + 1, cmp);
  for (int i = 1; i <= n; i++) hehe[i] = p[i].data / p[i].wei;
  l = 1;
  r = 0;
  for (int i = 1; i <= n; i++)
    if (p[i].wei > p[q[r]].wei) q[++r] = i;
  tot = n;
  for (int i = 1; i < r; i++) {
    hehe[++tot] =
        (p[q[i + 1]].data - p[q[i]].data) / (p[q[i + 1]].wei - p[q[i]].wei);
    if (hehe[tot] > hehe[n] || hehe[tot] < hehe[1]) tot--;
  }
  l = 1;
  r = 0;
  for (int i = n; i; i--)
    if (p[i].wei > p[q[r]].wei) q[++r] = i;
  for (int i = 1; i < r; i++) {
    hehe[++tot] =
        (p[q[i + 1]].data - p[q[i]].data) / (p[q[i]].wei - p[q[i + 1]].wei);
    if (hehe[tot] > hehe[n] || hehe[tot] < hehe[1]) tot--;
  }
  sort(hehe + 1, hehe + tot + 1);
  l = 1;
  r = 0;
  for (int i = 1; i <= n; i++)
    if (p[i].wei > p[q[r]].wei) q[++r] = i;
  for (int i = 1; i <= tot; i++) {
    while (l < r && hehe[i] * p[q[l]].wei - p[q[l]].data <
                        hehe[i] * p[q[l + 1]].wei - p[q[l + 1]].data)
      l++;
    minn[i] = hehe[i] * p[q[l]].wei - p[q[l]].data;
  }
  l = 1;
  r = 0;
  for (int i = n; i; i--)
    if (p[i].wei > p[q[r]].wei) q[++r] = i;
  for (int i = tot; i; i--) {
    while (l < r && p[q[l]].data - hehe[i] * p[q[l]].wei <
                        p[q[l + 1]].data - hehe[i] * p[q[l + 1]].wei)
      l++;
    maxx[i] = p[q[l]].data - hehe[i] * p[q[l]].wei;
  }
  ans = 1e10;
  for (int i = 1; i <= tot; i++) ans = min(ans, minn[i] + maxx[i]);
  cout << ans << endl;
  return 0;
}
