N = int(eval(input()))

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

dp = [float('inf') for i in range(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[N-1]))

  
N = int(eval(input()))

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

ans = [float('inf')]*N

ans[0] = 0

ans[1] = abs(A[0]-A[1])

for i in range(2,N):

  ans[i] = min(ans[i-1]+abs(A[i]-A[i-1]), ans[i-2]+abs(A[i]-A[i-2]))

print((ans[N-1]))
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [float("inf") for i in range(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[N - 1]))

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

-h = list(map(int, input().split())) -dp = [float("inf") for i in range(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[N - 1])) +A = list(map(int, input().split())) +ans = [float("inf")] * N +ans[0] = 0 +ans[1] = abs(A[0] - A[1]) +for i in range(2, N): +    ans[i] = min(ans[i - 1] + abs(A[i] - A[i - 1]), ans[i - 2] + abs(A[i] - A[i - 2])) +print((ans[N - 1]))