N = int(eval(input()))

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

def chmin(a, b):

    if a > b:

        return b

    else:

        return a

import numpy as np

dp_list = [np.inf] * N

dp_list[0] = 0

dp_list[1] = abs(h_list[1] - h_list[0])

for i in range(2, N):

    dp_list[i] = chmin(dp_list[i], dp_list[i-1] + abs(h_list[i-1] - h_list[i]))

    dp_list[i] = chmin(dp_list[i], dp_list[i-2] + abs(h_list[i-2] - h_list[i]))

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

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





dp_list = [0, abs(h_list[0] - h_list[1])]

for n in range(2, N):

    h0 = h_list[n-2]

    h1 = h_list[n-1]

    h2 = h_list[n]

    tmp_min = min(abs(h2-h1)+dp_list[n-1], abs(h2-h0)+dp_list[n-2])

    dp_list.append(tmp_min)

print((dp_list[-1]))

N = int(eval(input()))
h_list = list(map(int, input().split()))


def chmin(a, b):
    if a > b:
        return b
    else:
        return a


import numpy as np

dp_list = [np.inf] * N
dp_list[0] = 0
dp_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, N):
    dp_list[i] = chmin(dp_list[i], dp_list[i - 1] + abs(h_list[i - 1] - h_list[i]))
    dp_list[i] = chmin(dp_list[i], dp_list[i - 2] + abs(h_list[i - 2] - h_list[i]))
print((dp_list[-1]))

N = int(eval(input()))
h_list = list(map(int, input().split()))
dp_list = [0, abs(h_list[0] - h_list[1])]
for n in range(2, N):
    h0 = h_list[n - 2]
    h1 = h_list[n - 1]
    h2 = h_list[n]
    tmp_min = min(abs(h2 - h1) + dp_list[n - 1], abs(h2 - h0) + dp_list[n - 2])
    dp_list.append(tmp_min)
print((dp_list[-1]))

- - -def chmin(a, b): -    if a > b: -        return b -    else: -        return a - - -import numpy as np - -dp_list = [np.inf] * N -dp_list[0] = 0 -dp_list[1] = abs(h_list[1] - h_list[0]) -for i in range(2, N): -    dp_list[i] = chmin(dp_list[i], dp_list[i - 1] + abs(h_list[i - 1] - h_list[i])) -    dp_list[i] = chmin(dp_list[i], dp_list[i - 2] + abs(h_list[i - 2] - h_list[i])) +dp_list = [0, abs(h_list[0] - h_list[1])] +for n in range(2, N): +    h0 = h_list[n - 2] +    h1 = h_list[n - 1] +    h2 = h_list[n] +    tmp_min = min(abs(h2 - h1) + dp_list[n - 1], abs(h2 - h0) + dp_list[n - 2]) +    dp_list.append(tmp_min)