N, K = int(eval(input())), 2

*h, = list(map(int, input().split()))

a = [abs(h[0] - h[k]) for k in range(K)]

for n in range(N - K):

    a = a[1:] + [min([a[k] + abs(h[n + k] - h[n + K]) for k in range(K)])]

print((a[K - 1]))

n = int(eval(input()))

*H, = list(map(int, input().split()))

a, b = 0, abs(H[0]-H[1])

for i in range(2, n):

    a, b = b, min(a+abs(H[i]-H[i-2]), b+abs(H[i]-H[i-1]))

print(b)

N, K = int(eval(input())), 2
(*h,) = list(map(int, input().split()))
a = [abs(h[0] - h[k]) for k in range(K)]
for n in range(N - K):
    a = a[1:] + [min([a[k] + abs(h[n + k] - h[n + K]) for k in range(K)])]
print((a[K - 1]))

n = int(eval(input()))
(*H,) = list(map(int, input().split()))
a, b = 0, abs(H[0] - H[1])
for i in range(2, n):
    a, b = b, min(a + abs(H[i] - H[i - 2]), b + abs(H[i] - H[i - 1]))
print(b)

-N, K = int(eval(input())), 2 -(*h,) = list(map(int, input().split())) -a = [abs(h[0] - h[k]) for k in range(K)] -for n in range(N - K): -    a = a[1:] + [min([a[k] + abs(h[n + k] - h[n + K]) for k in range(K)])] -print((a[K - 1])) +n = int(eval(input())) +(*H,) = list(map(int, input().split())) +a, b = 0, abs(H[0] - H[1]) +for i in range(2, n): +    a, b = b, min(a + abs(H[i] - H[i - 2]), b + abs(H[i] - H[i - 1])) +print(b)