#import math

#import numpy as np



N =int(eval(input()))

#=input()

#=map(int, input().split())

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

#=[input(), input()]



dp = [0] * N

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



for i in range(2, N):

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

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

    dp[i] = min(t1, t2)



print((dp[-1]))

#!/usr/bin/env python3



#import

#import math

#import numpy as np

N = int(eval(input()))

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



dp = [10**9] * N

dp[0] = 0

for i in range(N - 1):

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

    

    if i < N - 2:

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



print((dp[-1]))
# import math
# import numpy as np
N = int(eval(input()))
# =input()
# =map(int, input().split())
h = list(map(int, input().split()))
# =[input(), input()]
dp = [0] * N
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    t1 = dp[i - 1] + abs(h[i] - h[i - 1])
    t2 = dp[i - 2] + abs(h[i] - h[i - 2])
    dp[i] = min(t1, t2)
print((dp[-1]))

#!/usr/bin/env python3
# import
# import math
# import numpy as np
N = int(eval(input()))
H = list(map(int, input().split()))
dp = [10**9] * N
dp[0] = 0
for i in range(N - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]))
    if i < N - 2:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))
print((dp[-1]))

+#!/usr/bin/env python3 +# import -# =input() -# =map(int, input().split()) -h = list(map(int, input().split())) -# =[input(), input()] -dp = [0] * N -dp[1] = abs(h[1] - h[0]) -for i in range(2, N): -    t1 = dp[i - 1] + abs(h[i] - h[i - 1]) -    t2 = dp[i - 2] + abs(h[i] - h[i - 2]) -    dp[i] = min(t1, t2) +H = list(map(int, input().split())) +dp = [10**9] * N +dp[0] = 0 +for i in range(N - 1): +    dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i])) +    if i < N - 2: +        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))