n = int(eval(input()))

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

dp = [0] * n

dp[0] = 0

dp[1] = abs(h[1]-h[0])

for i in range(2, n):

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

print((dp[-1]))

import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



N = int(eval(input()))

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



dp = [0 for _ in range(N)]

dp[1] = abs(h[1] - h[0])



for i in range(2, N):

    one = abs(h[i]-h[i-1])+dp[i-1]

    two = abs(h[i]-h[i-2])+dp[i-2]

    dp[i] = min(one, two)





print((dp[-1]))

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

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [0 for _ in range(N)]
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    one = abs(h[i] - h[i - 1]) + dp[i - 1]
    two = abs(h[i] - h[i - 2]) + dp[i - 2]
    dp[i] = min(one, two)
print((dp[-1]))

-n = int(eval(input())) +import sys + +input = sys.stdin.readline +sys.setrecursionlimit(10**7) +N = int(eval(input())) -dp = [0] * n -dp[0] = 0 +dp = [0 for _ in range(N)] -for i in range(2, n): -    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) +for i in range(2, N): +    one = abs(h[i] - h[i - 1]) + dp[i - 1] +    two = abs(h[i] - h[i - 2]) + dp[i - 2] +    dp[i] = min(one, two)