#dp educational contest a frog1 漸化式

n=int(eval(input()))

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

dp=[0]*n

for i in range(1,n):

    if i==1:

        dp[i]=abs(h[i]-h[i-1]) #０番目と１番目の差

    else:

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

ans=dp[n-1]

print(ans)
#a

n=int(eval(input()))

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



N=100010

dp=[0]*N



for i in range(1,n):

    if i==1:

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

    else:

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



print((dp[n-1]))

# dp educational contest a frog1 漸化式
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
for i in range(1, n):
    if i == 1:
        dp[i] = abs(h[i] - h[i - 1])  # ０番目と１番目の差
    else:
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
ans = dp[n - 1]
print(ans)

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

-# dp educational contest a frog1 漸化式 +# a -dp = [0] * n +N = 100010 +dp = [0] * N -        dp[i] = abs(h[i] - h[i - 1])  # ０番目と１番目の差 +        dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]) -        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) -ans = dp[n - 1] -print(ans) +        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i])) +print((dp[n - 1]))