N = gets.to_i A = gets.split.map(&:to_i) ans = (1..100).map {|m| p, q = (1..199).zip(A).map {|i, a| [m - (m - i).abs, 0].max - a.to_i }.inject([0, 0]) {|(p, q), x| [p + [0, x].max, q - [0, x].min] } if q >= p q else Float::INFINITY end }.min puts ans