n = int(eval(input()))

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

dp = [float("inf") for i in range(n)]

dp[0] = 0

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

for i in range(1, n):

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

print((dp[n - 1]))
import sys

reader = (s.rstrip() for s in sys.stdin)

input = reader.__next__

sys.setrecursionlimit(1000000)

# do magic here

n = int(eval(input()))

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



dp = [0 for x in range(n+1)]



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



for x in range(2, n):

    a = abs(heights[x]-heights[x-1]) + dp[x-1]

    b = abs(heights[x]-heights[x-2]) + dp[x-2]

    dp[x] = min(a, b)



print((dp[n-1]))

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

import sys

reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
sys.setrecursionlimit(1000000)
# do magic here
n = int(eval(input()))
heights = [int(x) for x in input().split()]
dp = [0 for x in range(n + 1)]
dp[1] = abs(heights[1] - heights[0])
for x in range(2, n):
    a = abs(heights[x] - heights[x - 1]) + dp[x - 1]
    b = abs(heights[x] - heights[x - 2]) + dp[x - 2]
    dp[x] = min(a, b)
print((dp[n - 1]))

+import sys + +reader = (s.rstrip() for s in sys.stdin) +input = reader.__next__ +sys.setrecursionlimit(1000000) +# do magic here -h = list(map(int, input().split())) -dp = [float("inf") for i in range(n)] -dp[0] = 0 -dp[1] = dp[0] + (h[1] - h[0]) -for i in range(1, n): -    dp[i] = min(dp[i - 2] + (abs(h[i] - h[i - 2])), dp[i - 1] + (abs(h[i] - h[i - 1]))) +heights = [int(x) for x in input().split()] +dp = [0 for x in range(n + 1)] +dp[1] = abs(heights[1] - heights[0]) +for x in range(2, n): +    a = abs(heights[x] - heights[x - 1]) + dp[x - 1] +    b = abs(heights[x] - heights[x - 2]) + dp[x - 2] +    dp[x] = min(a, b)