Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
max_Ad = max(map(abs, Ad))
min_total = float("inf")

for b in range(-max_Ad, max_Ad+1):
    Ad = list(map(lambda x: x-b, Ad))
    total = sum(map(abs, Ad))
    if min_total > total:
        min_total = total
print(min_total)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
Ad.sort()
l = len(Ad)
if l % 2 == 1:
    b = Ad[l//2]
    ans = sum(map(lambda x:abs(x-b), Ad))
else:
    b1, b2 = Ad[l//2], Ad[l//2-1]
    ans = min(sum(map(lambda x:abs(x-b1), Ad)), sum(map(lambda x:abs(x-b2), Ad)))
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
max_Ad = max(abs(Ad))
min_total = float("inf")

for b in range(0, max_Ad+1):
    map(lambda x: x-b, Ad)
    total = sum(abs(Ad))
    if min_total > total:
        min_total = total
print(min_total)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
Ad.sort()
l = len(Ad)
if l % 2 == 1:
    b = Ad[l//2]
    ans = sum(map(lambda x:abs(x-b), Ad))
else:
    b1, b2 = Ad[l//2], Ad[l//2-1]
    ans = min(sum(map(lambda x:abs(x-b1), Ad)), sum(map(lambda x:abs(x-b2), Ad)))
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
max_Ad = max(abs(Ad))
min_total = float("inf")

for b in range(0, max_Ad+1):
    map(lambda x: x-b, Ad)
    total = sum(abs(Ad))
    if min_total > total:
        min_total = total
print(min_total)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
Ad.sort()
l = len(Ad)
if l % 2 == 1:
    b = Ad[l//2]
    ans = sum(map(lambda x:abs(x-b), Ad))
else:
    b1, b2 = Ad[l//2], Ad[l//2-1]
    ans = min(sum(map(lambda x:abs(x-b1), Ad)), sum(map(lambda x:abs(x-b2), Ad)))
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
max_Ad = max(abs(Ad))
min_total = float("inf")

for b in range(0, max_Ad+1):
    map(lambda x: x-b, Ad)
    total = sum(abs(Ad))
    if min_total > total:
        min_total = total
print(min_total)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
Ad.sort()
l = len(Ad)
if l % 2 == 1:
    b = Ad[l//2]
    ans = sum(map(lambda x:abs(x-b), Ad))
else:
    b1, b2 = Ad[l//2], Ad[l//2-1]
    ans = min(sum(map(lambda x:abs(x-b1), Ad)), sum(map(lambda x:abs(x-b2), Ad)))
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
max_Ad = max(abs(Ad))
min_total = float("inf")

for b in range(0, max_Ad+1):
    map(lambda x: x-b, Ad)
    total = sum(abs(Ad))
    if min_total > total:
        min_total = total
print(min_total)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
Ad.sort()
l = len(Ad)
if l % 2 == 1:
    b = Ad[l//2]
    ans = sum(map(lambda x:abs(x-b), Ad))
else:
    b1, b2 = Ad[l//2], Ad[l//2-1]
    ans = min(sum(map(lambda x:abs(x-b1), Ad)), sum(map(lambda x:abs(x-b2), Ad)))
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
max_Ad = max(abs(Ad))
min_total = float("inf")

for b in range(0, max_Ad+1):
    map(lambda x: x-b, Ad)
    total = sum(abs(Ad))
    if min_total > total:
        min_total = total
print(min_total)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
Ad.sort()
l = len(Ad)
if l % 2 == 1:
    b = Ad[l//2]
    ans = sum(map(lambda x:abs(x-b), Ad))
else:
    b1, b2 = Ad[l//2], Ad[l//2-1]
    ans = min(sum(map(lambda x:abs(x-b1), Ad)), sum(map(lambda x:abs(x-b2), Ad)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
max_A = 0
max_i = 0
total = 0
min_total = float("inf")

for i, v in enumerate(A):
    if v > max_A:
        max_A = v
        max_i = i

for b in range(-1*abs(max_A - max_i), (max_A - max_i)+1):
    total = 0
    for i in range(N):
        total += abs(A[i]-(b+i))
    if min_total > total:
        min_total = total

print(min_total)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
Ad.sort()
l = len(Ad)
if l % 2 == 1:
    b = Ad[l//2]
    ans = sum(map(lambda x:abs(x-b), Ad))
else:
    b1, b2 = Ad[l//2], Ad[l//2-1]
    ans = min(sum(map(lambda x:abs(x-b1), Ad)), sum(map(lambda x:abs(x-b2), Ad)))
print(ans)