#include <bits/stdc++.h>
using namespace std;
int n, x;
long long miny = 0;
priority_queue<int> l;
int main() {
cin >> n;
for(int i=0;i<n;i++) {
cin >> x; x-=i;
if(l.empty()) {
l.push(x);
} else {
if(x <= l.top()) { //x is between l and r
miny += l.top()-x;
l.push(x); l.push(x); l.pop();
} else {
l.push(x);
}
}
}
cout << miny;
}
950A - Left-handers Right-handers and Ambidexters | 672B - Different is Good |
1C - Ancient Berland Circus | 721A - One-dimensional Japanese Crossword |
1715B - Beautiful Array | 60B - Serial Time |
453A - Little Pony and Expected Maximum | 1715A - Crossmarket |
1715C - Monoblock | 1512C - A-B Palindrome |
1679B - Stone Age Problem | 402A - Nuts |
792A - New Bus Route | 221A - Little Elephant and Function |
492C - Vanya and Exams | 1369B - AccurateLee |
892B - Wrath | 999A - Mishka and Contest |
727C - Guess the Array | 1625C - Road Optimization |
1715D - 2+ doors | 267A - Subtractions |
1582A - Luntik and Concerts | 560A - Currency System in Geraldion |
946A - Partition | 1068B - LCM |
1692E - Binary Deque | 679A - Bear and Prime 100 |
488A - Giga Tower | 14A - Letter |