n = int(eval(input()))

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

tmp = [float('inf') for i in range(n)]



tmp[0] = 0

tmp[1] = abs(arr[0] - arr[1])

for j in range(2,n):

	tmp[j] = min(tmp[j],tmp[j-2]+abs(arr[j-2]-arr[j]))

	tmp[j] = min(tmp[j],tmp[j-1]+abs(arr[j-1]-arr[j]))

print((tmp[-1]))







n = int(eval(input()))



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



dp = [float('inf')] * n



dp[0] = 0

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



for i in range(2,n):

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



print((dp[-1]))

	

	



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

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

-tmp = [float("inf") for i in range(n)] -tmp[0] = 0 -tmp[1] = abs(arr[0] - arr[1]) -for j in range(2, n): -    tmp[j] = min(tmp[j], tmp[j - 2] + abs(arr[j - 2] - arr[j])) -    tmp[j] = min(tmp[j], tmp[j - 1] + abs(arr[j - 1] - arr[j])) -print((tmp[-1])) +dp = [float("inf")] * n +dp[0] = 0 +dp[1] = abs(arr[0] - arr[1]) +for i in range(2, n): +    dp[i] = min( +        abs(arr[i - 1] - arr[i]) + dp[i - 1], abs(arr[i - 2] - arr[i]) + dp[i - 2] +    ) +print((dp[-1]))