dp = [0]*(110000)

A = int(eval(input()))

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

for i in range(1,A):

    if i == 1:

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

    else:

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

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

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

dp = [0] * 110000

for i in range(1,N):

  if i == 1:

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

  else:

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

print((dp[N-1]))
dp = [0] * (110000)
A = int(eval(input()))
h = list(map(int, input().split()))
for i in range(1, A):
    if i == 1:
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
    else:
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[A - 1]))

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

-dp = [0] * (110000) -A = int(eval(input())) +N = int(eval(input())) -for i in range(1, A): +dp = [0] * 110000 +for i in range(1, N): -        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]) +        dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]) -        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) -print((dp[A - 1])) +        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i])) +print((dp[N - 1]))