# EduDPA - Frog 1

n = int(eval(input()))

lst = list(map(int, input().rstrip().split()))

ans = [0, abs(lst[0] - lst[1])] + [float("inf")] * (n - 2)

for i in range(2, n):

    ans[i] = min(ans[i], ans[i - 1] + abs(lst[i] - lst[i - 1]))

    ans[i] = min(ans[i], ans[i - 2] + abs(lst[i] - lst[i - 2]))



print((ans[-1]))
# EduDPA - Frog 1

n = int(eval(input()))

lst = list(map(int, input().rstrip().split()))

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

for i in range(2, n):

    dif_1 = a + abs(lst[i] - lst[i - 2])

    dif_2 = b + abs(lst[i] - lst[i - 1])

    a, b = b, min(dif_1, dif_2)

print(b)
# EduDPA - Frog 1
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
ans = [0, abs(lst[0] - lst[1])] + [float("inf")] * (n - 2)
for i in range(2, n):
    ans[i] = min(ans[i], ans[i - 1] + abs(lst[i] - lst[i - 1]))
    ans[i] = min(ans[i], ans[i - 2] + abs(lst[i] - lst[i - 2]))
print((ans[-1]))

# EduDPA - Frog 1
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
a, b = 0, abs(lst[0] - lst[1])
for i in range(2, n):
    dif_1 = a + abs(lst[i] - lst[i - 2])
    dif_2 = b + abs(lst[i] - lst[i - 1])
    a, b = b, min(dif_1, dif_2)
print(b)

-ans = [0, abs(lst[0] - lst[1])] + [float("inf")] * (n - 2) +a, b = 0, abs(lst[0] - lst[1]) -    ans[i] = min(ans[i], ans[i - 1] + abs(lst[i] - lst[i - 1])) -    ans[i] = min(ans[i], ans[i - 2] + abs(lst[i] - lst[i - 2])) -print((ans[-1])) +    dif_1 = a + abs(lst[i] - lst[i - 2]) +    dif_2 = b + abs(lst[i] - lst[i - 1]) +    a, b = b, min(dif_1, dif_2) +print(b)