Buggy python submission (verdict: Runtime Error):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)/2 +1
else:
    mid = N / 2
b = a[mid]

sadness_left = b * (mid-1) - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)


Fixed submission:
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

Buggy python submission (verdict: Time Limit Exceeded):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
max = a[-1]
min = a[0]

for b in range(min, max + 1):
    sadness_left = 0
    i = 0
    while a[i] < b:
        sadness_left += b - a[i]
        i += 1
    sadness = sum(a) - b * N + sadness_left * 2
    if b == min:
        min_sadness = sadness
    elif min_sadness > sadness:
        min_sadness = sadness

print(min_sadness)


Fixed submission:
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

Buggy python submission (verdict: Time Limit Exceeded):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

#sum = 0
max = a[0]-1
min = a[0]-1
for i in range(N):
    a[i] = a[i] - (i+1)
    #sum += a[i]
    if a[i] > max:
        max = a[i]
    if a[i] < min:
        min = a[i]
a.sort()

for b in range(min, max + 1):
    sadness_left = 0
    i = 0
    while a[i] < b:
        sadness_left += b - a[i]
        i += 1
    sadness = sum(a) - b * N + sadness_left * 2
    if b == min:
        min_sadness = sadness
    elif min_sadness > sadness:
        min_sadness = sadness

print(min_sadness)


Fixed submission:
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

Buggy python submission (verdict: Time Limit Exceeded):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

sum = 0
max = a[0]-1
min = a[0]-1
for i in range(N):
    a[i] = a[i] - (i+1)
    sum += a[i]
    if a[i] > max:
        max = a[i]
    if a[i] < min:
        min = a[i]


for b in range(min, max + 1):
    sadness = 0
    for i in range(N):
        if a[i] > b:
            sadness += a[i] - b
        else:
            sadness += b - a[i]
    if b == min:
        min_sadness = sadness
    elif min_sadness > sadness:
        min_sadness = sadness

print(min_sadness)


Fixed submission:
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

Buggy python submission (verdict: Time Limit Exceeded):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

sum = 0
max = a[0]-1
min = a[0]-1
for i in range(N):
    a[i] = a[i] - (i+1)
    sum += a[i]
    if a[i] > max:
        max = a[i]
    if a[i] < min:
        min = a[i]

sadnesses = []

for b in range(min, max + 1):
    sadness = 0
    for i in range(N):
        if a[i] > b:
            sadness += a[i] - b
        else:
            sadness += b - a[i]
    sadnesses.append(sadness)

sadnesses.sort()
print(sadnesses[0])


Fixed submission:
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

Buggy python submission (verdict: Time Limit Exceeded):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

sum = 0
for i in range(N):
    a[i] = a[i] - (i+1)
    sum += a[i]
#print(a)
A = a[:]
A.sort()
max = A[-1]
min = A[0]

sadnesses = []

for b in range(min, max + 1):
    sadness = 0
    for i in range(N):
        if a[i] > b:
            sadness += a[i] - b
        else:
            sadness += b - a[i]
    sadnesses.append(sadness)

sadnesses.sort()
print(sadnesses[0])


Fixed submission:
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)