from sys import stdin as I

from sys import stdout as O

N = int(I.readline())

H = [None] + list(map(int,I.readline().split()))

DP = [None for i in range(N+1)]

DP[1] = 0

DP[2] = abs(H[2]-H[1])

for i in range(3,N+1):DP[i] = min(DP[i-2]+abs(H[i]-H[i-2]),DP[i-1]+abs(H[i]-H[i-1]))

print((DP[N]))
N = int(eval(input()))

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

dp = [0, abs(h[1] - h[0])] + [0] * (N - 2)

for i in range(2, N):

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

print((dp[N-1]))
from sys import stdin as I
from sys import stdout as O

N = int(I.readline())
H = [None] + list(map(int, I.readline().split()))
DP = [None for i in range(N + 1)]
DP[1] = 0
DP[2] = abs(H[2] - H[1])
for i in range(3, N + 1):
    DP[i] = min(DP[i - 2] + abs(H[i] - H[i - 2]), DP[i - 1] + abs(H[i] - H[i - 1]))
print((DP[N]))

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

-from sys import stdin as I -from sys import stdout as O - -N = int(I.readline()) -H = [None] + list(map(int, I.readline().split())) -DP = [None for i in range(N + 1)] -DP[1] = 0 -DP[2] = abs(H[2] - H[1]) -for i in range(3, N + 1): -    DP[i] = min(DP[i - 2] + abs(H[i] - H[i - 2]), DP[i - 1] + abs(H[i] - H[i - 1])) -print((DP[N])) +N = int(eval(input())) +h = [*list(map(int, input().split()))] +dp = [0, abs(h[1] - h[0])] + [0] * (N - 2) +for i in range(2, N): +    dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]) +print((dp[N - 1]))