#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e3 + 100;
long long arr[MAXN];
long long dp[MAXN][MAXN];
vector<long long> nums;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i] -= i;
    nums.push_back(arr[i]);
  }
  sort(nums.begin(), nums.end());
  dp[0][0] = abs(arr[0] - nums[0]);
  for (int i = 1; i < nums.size(); i++)
    dp[0][i] = min(dp[0][i - 1], abs(arr[0] - nums[i]));
  for (int i = 1; i < n; i++) {
    dp[i][0] = dp[i - 1][0] + abs(arr[i] - nums[0]);
    for (int j = 1; j < nums.size(); j++)
      dp[i][j] = min(dp[i][j - 1], abs(arr[i] - nums[j]) + dp[i - 1][j]);
  }
  cout << dp[n - 1][nums.size() - 1] << endl;
  return 0;
}
