#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
const double INF = 1LL<<60;

double calc(double cur, double next, double h) {
    if ((cur-h) * (next-h) >= 0) {
        return (abs(cur-h) + abs(next-h)) / 2;
    }
    else {
        double a = abs(cur - h), b = abs(next - h);
        return (a*a + b*b) / (a + b) / 2;
    }
}

int main() {
    int N; cin >> N;
    vector<double> H(N);
    for (int i = 0; i < N; ++i) cin >> H[i];

    vector<vector<double> > dp(N+1, vector<double>(300, INF));
    dp[0][1] = 0;
    for (int i = 0; i < N; ++i) {
        for (int h = 1; h < 300; ++h) {
            for (int h2 = 1; h2 < 300; ++h2) {
                dp[i+1][h2] = min(dp[i+1][h2], dp[i][h] + calc(h, h2, H[i]));
            }
        }
    }
    double res = INF;
    for (int h = 1; h < 300; ++h) res = min(res, dp[N][h]);
    cout << fixed << setprecision(10) << res << endl;
}

