n = int(eval(input()))

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



dp = [10**9+1]*n

dp[0] = 0

dp[1] = dp[0] + abs(a[1]-a[0])



for i in range(2, n):

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



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

dp = [0]*(n+1)

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

  

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

for i in range(2,n):

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

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

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

+dp = [0] * (n + 1) -dp = [10**9 + 1] * n -dp[0] = 0 -dp[1] = dp[0] + abs(a[1] - a[0]) +dp[1] = abs(a[1] - a[0]) -    dp[i] = min([dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2])]) +    dp[i] = min(dp[i - 2] + abs(a[i] - a[i - 2]), dp[i - 1] + abs(a[i] - a[i - 1]))