#include #include #include #include #include using namespace std; int main() { int n; cin >> n; vector a(2 * n - 1, 0); for (int i = 0; i < n; i++) { cin >> a[i]; } vector b(2 * n - 1, 0); int ans = 1e9; for (int center = 0; center < n; center++) { fill(b.begin(), b.end(), 0); int i; for (i = 0; i <= center; i++) { b[i] = i + 1; } for ( ; b[i - 1] > 0; i++) { b[i] = b[i - 1] - 1; } int more = 0; int less = 0; for (int j = 0; j < a.size(); j++) { int diff = a[j] - b[j]; if (diff > 0) { more += diff; } else { less += -diff; } } if (more >= less) { ans = min(ans, more); } } cout << ans << endl; return 0; }