#!/usr/bin/env python3







N = int(eval(input()))

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



dp = [float('inf') for i in range(N+1)]



dp[1] = 0

dp[2] = abs(H[1]-H[0])

for i in range(3, N+1):

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



print((dp[N]))

#!/usr/bin/env python3



N = int(eval(input()))

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



dp = [float('inf') for _ in range(N+1)]

dp[1] = 0

dp[2] = abs(H[0]-H[1])



for i in range(3, N+1):

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



print((dp[N]))

#!/usr/bin/env python3
N = int(eval(input()))
H = list(map(int, input().split()))
dp = [float("inf") for i in range(N + 1)]
dp[1] = 0
dp[2] = abs(H[1] - H[0])
for i in range(3, N + 1):
    dp[i] = min(
        dp[i - 1] + abs(H[i - 1] - H[i - 2]), dp[i - 2] + abs(H[i - 1] - H[i - 3])
    )
print((dp[N]))

#!/usr/bin/env python3
N = int(eval(input()))
H = list(map(int, input().split()))
dp = [float("inf") for _ in range(N + 1)]
dp[1] = 0
dp[2] = abs(H[0] - H[1])
for i in range(3, N + 1):
    dp[i] = min(
        dp[i - 2] + abs(H[i - 3] - H[i - 1]), dp[i - 1] + abs(H[i - 2] - H[i - 1])
    )
print((dp[N]))

-dp = [float("inf") for i in range(N + 1)] +dp = [float("inf") for _ in range(N + 1)] -dp[2] = abs(H[1] - H[0]) +dp[2] = abs(H[0] - H[1]) -        dp[i - 1] + abs(H[i - 1] - H[i - 2]), dp[i - 2] + abs(H[i - 1] - H[i - 3]) +        dp[i - 2] + abs(H[i - 3] - H[i - 1]), dp[i - 1] + abs(H[i - 2] - H[i - 1])