import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    const int H = 500;

    auto dp = new real[][](N+1, H+1);
    foreach (i; 0..N+1) dp[i][] = 1L << 59;
    dp[0][1] = 0;

    foreach (i; 0..N) {
        foreach (j; 1..H+1) {
            if (dp[i][j] == 1L << 59) continue;
            foreach (k; 1..H+1) {
                real hj = abs(A[i] - j);
                real hk = abs(A[i] - k);
                real v;
                if (j < A[i] && k < A[i]) {
                    v = (hj + hk) / 2.0L;
                } else if (j < A[i] && k > A[i]) {
                    real a = 1.0L * hj / (hj + hk);
                    real b = 1.0L * hk / (hj + hk);
                    v = hj * a / 2.0L + hk * b / 2.0L;
                } else if (j > A[i] && k > A[i]) {
                    v = (hj + hk) / 2.0L;
                } else if (j > A[i] && k < A[i]) {
                    real a = 1.0L * hj / (hj + hk);
                    real b = 1.0L * hk / (hj + hk);
                    v = hj * a / 2.0L + hk * b / 2.0L;
                } else {
                    v  = (hj + hk) / 2.0L;
                }
                dp[i+1][k] = min(dp[i+1][k], dp[i][j] + v);
            }
        }
    }

    writefln("%.15f", dp[N].reduce!min);
}

