import numpy as np



N = int(eval(input()))

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



memo = np.zeros(N)

memo[0] = 0

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



for i in range(2,N):

  a = memo[i-1] + abs(h[i] - h[i-1])

  b = memo[i-2] + abs(h[i] - h[i-2])

  memo[i] = min(a,b)



print((int(memo[N-1])))
n = int(eval(input()))

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

dp = [10**7]*n

dp[0] = 0

for i in range(1,n):

  dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(3,i+1))])

print((dp[n-1]))

  
import numpy as np

N = int(eval(input()))
h = list(map(int, input().split()))
memo = np.zeros(N)
memo[0] = 0
memo[1] = abs(h[0] - h[1])
for i in range(2, N):
    a = memo[i - 1] + abs(h[i] - h[i - 1])
    b = memo[i - 2] + abs(h[i] - h[i - 2])
    memo[i] = min(a, b)
print((int(memo[N - 1])))

n = int(eval(input()))
h = list(map(int, input().split()))
dp = [10**7] * n
dp[0] = 0
for i in range(1, n):
    dp[i] = min([dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, min(3, i + 1))])
print((dp[n - 1]))

-import numpy as np - -N = int(eval(input())) +n = int(eval(input())) -memo = np.zeros(N) -memo[0] = 0 -memo[1] = abs(h[0] - h[1]) -for i in range(2, N): -    a = memo[i - 1] + abs(h[i] - h[i - 1]) -    b = memo[i - 2] + abs(h[i] - h[i - 2]) -    memo[i] = min(a, b) -print((int(memo[N - 1]))) +dp = [10**7] * n +dp[0] = 0 +for i in range(1, n): +    dp[i] = min([dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, min(3, i + 1))]) +print((dp[n - 1]))