import numpy as np

N= int(eval(input()))

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

dp = np.zeros(N, dtype = int)





for i in range(N - 1):

    if i == 0:

        dp[i + 1] = abs(H[0] - H[1])

    else:

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

                        dp[i - 1] + abs(H[i - 1] - H[i + 1]))



#print(dp)

print((dp[N - 1]))

N= int(eval(input()))

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

rev, cur, tmp = 0, 0, 0

for i in range(N - 1):

  if i == 0:

    cur = abs(H[0] - H[1])

  else:

    tmp = cur

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

              rev + abs(H[i - 1] - H[i + 1]))

    rev = tmp

print(cur)

import numpy as np

N = int(eval(input()))
H = list(map(int, input().split()))
dp = np.zeros(N, dtype=int)
for i in range(N - 1):
    if i == 0:
        dp[i + 1] = abs(H[0] - H[1])
    else:
        dp[i + 1] = min(
            dp[i] + abs(H[i] - H[i + 1]), dp[i - 1] + abs(H[i - 1] - H[i + 1])
        )
# print(dp)
print((dp[N - 1]))

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

-import numpy as np - -dp = np.zeros(N, dtype=int) +rev, cur, tmp = 0, 0, 0 -        dp[i + 1] = abs(H[0] - H[1]) +        cur = abs(H[0] - H[1]) -        dp[i + 1] = min( -            dp[i] + abs(H[i] - H[i + 1]), dp[i - 1] + abs(H[i - 1] - H[i + 1]) -        ) -# print(dp) -print((dp[N - 1])) +        tmp = cur +        cur = min(cur + abs(H[i] - H[i + 1]), rev + abs(H[i - 1] - H[i + 1])) +        rev = tmp +print(cur)