Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
#import numpy as np
import statistics
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=list(map(int,input().split()))

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


    val=0
    for i in A:
        val += abs(i - statistics.median(A))
    print(int(val))
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Buggy python submission (verdict: Runtime Error):
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
#import numpy as np
import statistics
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=list(map(int,input().split()))

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


    val=0
    for i in A:
        val += abs(i - statistics.median(A))
    print(int(val))
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Buggy python submission (verdict: Runtime Error):
import statistics
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

    B=np.array([i for i in range(1,N+1)])

    A=A-B
    val=0
    for i in A:
        val += abs(i - statistics.median(A))
    print(int(val))
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Buggy python submission (verdict: Runtime Error):
import statistics
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

    B=np.array([i for i in range(1,N+1)])

    A=A-B
    val=0
    for i in A:
        val += abs(i - statistics.median(A))
    print(int(val))
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

    B=np.array([i for i in range(1,N+1)])

    A=A-B
    val=0
    for i in A:
        val += abs(i - np.median(A))
    print(int(val))
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))
    
    B=np.array([i for i in range(1,N+1)])
    
    A=A-B


    val1 = 0
    val2=0
    for i in A:
        val1 += abs(i - 1)
        val2+=abs(i+1)
    if val1<val2:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i-j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1

    else:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i+j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1
    print(minval)
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):

def resolve():
    N=int(input())
    A=list(map(int,input().split()))

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

    val1 = 0
    val2=0
    for i in A:
        val1 += abs(i - 1)
        val2+=abs(i+1)
    if val1<val2:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i-j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1

    else:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i+j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1
    print(minval)
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):

def resolve():
    N=int(input())
    A=list(map(int,input().split()))

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

    val1 = 0
    val2=0
    for i in A:
        val1 += abs(i - 1)
        val2+=abs(i+1)
    if val1<val2:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i-j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1

    else:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i+j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1
    print(minval)
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):

def resolve():
    N=int(input())
    A=list(map(int,input().split()))

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

    minval = 10 ** 50
    j=0
    temp = 10**50
    while True:
        val=0
        for i in A:
            val+=abs(i-j)
        if val>=temp:
            break
        else:
            temp=val
            minval=min(minval,val)
            j+=1

    minval = 10 ** 50
    j=0
    temp = 10**50
    while True:
        val=0
        for i in A:
            val+=abs(i+j)
        if val>=temp:
            break
        else:
            temp=val
            minval=min(minval,val)
            j+=1
    print(minval)
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):

def resolve():
    N=int(input())
    A=list(map(int,input().split()))

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

    minval = 10 ** 50
    j=0
    temp = 10**50
    while True:
        val=0
        for i in A:
            val+=abs(i-j)
        if val>=temp:
            break
        else:
            temp=val
            minval=min(minval,val)
            j+=1

    minval = 10 ** 50
    j=0
    temp = 10**50
    while True:
        val=0
        for i in A:
            val+=abs(i+j)
        if val>=temp:
            break
        else:
            temp=val
            minval=min(minval,val)
            j+=1
    print(minval)
resolve()

Fixed submission:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

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

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()