import numpy as np

Nmax = 10**5



N = int(eval(input()))

h = [int(x) for x in input().split()]



dp = np.zeros(Nmax + 1)



dp[0] = 0

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



for i in range(2, N):

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



print((int(dp[N-1])))
import numpy as np

Nmax = 10**5



N = int(eval(input()))

h = [int(x) for x in input().split()]



dp = [0] * (Nmax + 1)



dp[0] = 0

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



for i in range(2, N):

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



print((int(dp[N-1])))

import numpy as np

Nmax = 10**5
N = int(eval(input()))
h = [int(x) for x in input().split()]
dp = np.zeros(Nmax + 1)
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
print((int(dp[N - 1])))

import numpy as np

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

-dp = np.zeros(Nmax + 1) +dp = [0] * (Nmax + 1)