n = int(eval(input()))

a = list(map(int,input().split()))

aa = []

for i in range(n):

    aa.append(a[i]-(i+1))

b = (sorted(aa)[n//2])



ans = 0

for i in range(n):

    ans += abs(a[i]-(b+i+1))

print(ans)
N= int(eval(input()))

A = list(map(int,input().split()))



B = []

for i in range(N):

    B.append(A[i]-(i+1))

#print(B)

b= (sorted(B)[N//2])

#print(b)

ans = 0

for i in range(N):

    ans += abs(B[i]-b)

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
aa = []
for i in range(n):
    aa.append(a[i] - (i + 1))
b = sorted(aa)[n // 2]
ans = 0
for i in range(n):
    ans += abs(a[i] - (b + i + 1))
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
B = []
for i in range(N):
    B.append(A[i] - (i + 1))
# print(B)
b = sorted(B)[N // 2]
# print(b)
ans = 0
for i in range(N):
    ans += abs(B[i] - b)
print(ans)

-n = int(eval(input())) -a = list(map(int, input().split())) -aa = [] -for i in range(n): -    aa.append(a[i] - (i + 1)) -b = sorted(aa)[n // 2] +N = int(eval(input())) +A = list(map(int, input().split())) +B = [] +for i in range(N): +    B.append(A[i] - (i + 1)) +# print(B) +b = sorted(B)[N // 2] +# print(b) -for i in range(n): -    ans += abs(a[i] - (b + i + 1)) +for i in range(N): +    ans += abs(B[i] - b)