N = int(eval(input()))

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

H = [0]*N

for i in range(1,N):

    if i == 1:

        H[i] = abs(h[1]-h[0])

    else:

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

print((H[N-1]))
N = int(eval(input()))

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

H = [0]*N

for i in range(1,N):

    if i == 1:

        H[i] = abs(h[1]-h[0])

    else:

        H[i] = H[i-1]+abs(h[i]-h[i-1])

        if H[i] > H[i-2]+abs(h[i]-h[i-2]):

            H[i] = H[i-2]+abs(h[i]-h[i-2])

print((H[N-1]))

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

N = int(eval(input()))
h = list(map(int, input().split()))
H = [0] * N
for i in range(1, N):
    if i == 1:
        H[i] = abs(h[1] - h[0])
    else:
        H[i] = H[i - 1] + abs(h[i] - h[i - 1])
        if H[i] > H[i - 2] + abs(h[i] - h[i - 2]):
            H[i] = H[i - 2] + abs(h[i] - h[i - 2])
print((H[N - 1]))

-        H[i] = min(H[i - 1] + abs(h[i] - h[i - 1]), H[i - 2] + abs(h[i] - h[i - 2])) +        H[i] = H[i - 1] + abs(h[i] - h[i - 1]) +        if H[i] > H[i - 2] + abs(h[i] - h[i - 2]): +            H[i] = H[i - 2] + abs(h[i] - h[i - 2])