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


import java.math.BigDecimal;
import java.util.Scanner;

public class WeaknessPoorness2 {

    public static final double ERR = 10e-7;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        double result = ternarySearch(a);
        System.out.printf("%.10f", result);
    }

    private static double ternarySearch(int[] arr) {
        double gr = (Math.sqrt(5) - 1) / 2;
        double a = -10000;
        double b = 10000;
        double c = b - gr * (b - a);
        double d = a + gr * (b - a);
        double fc = weakness(arr, c);
        double fd = weakness(arr, d);

        while (Math.abs(c - d) > ERR) {
            if (fc<fd) {
                b = d;
                d = c;
                fd = fc;
                fc = weakness(arr, c);
                c = b - gr * (b - a);
            }
            else {
                a = c;
                c = d;
                fc = fd;
                fd = weakness(arr, d);
                d = a + gr * (b - a);
            }
        }

        return weakness(arr, (a + b) / 2);
    }

    private static double weakness(int[] a, double x) {
        BigDecimal maxSum = new BigDecimal(Integer.MIN_VALUE);
        BigDecimal minSum = new BigDecimal(Integer.MAX_VALUE);

//        double curMax = 0;
//        double curMin = 0;
        BigDecimal curMax = BigDecimal.ZERO;
        BigDecimal curMin = BigDecimal.ZERO;
        for (int anA : a) {
            BigDecimal num = new BigDecimal(anA - x);
            curMax = curMax.add(num);
            curMin = curMin.add(num);
            if (curMax.compareTo(maxSum) > 0) {
                maxSum = curMax;
            }
            if (curMin.compareTo(minSum) < 0) {
                minSum = curMin;
            }
            if (curMax.compareTo(BigDecimal.ZERO) < 0) {
                curMax = BigDecimal.ZERO;
            }
            if (curMin.compareTo(BigDecimal.ZERO) > 0) {
                curMin = BigDecimal.ZERO;
            }
        }
        return Math.max(Math.abs(minSum.doubleValue()), Math.abs(maxSum.doubleValue()));
    }
}
