N = int(eval(input()))

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

dp = [0] + [10**10]*N

for i,h in enumerate(a):

    for j in range(i+1,min(i+3,N)):

        dp[j] = min(dp[j],dp[i]+abs(h-a[j]))

    #print(dp)

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

dp = [0]+ [float("INF")]*(n)



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

for i in range(n):

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

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

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

-N = int(eval(input())) -a = list(map(int, input().split())) -dp = [0] + [10**10] * N -for i, h in enumerate(a): -    for j in range(i + 1, min(i + 3, N)): -        dp[j] = min(dp[j], dp[i] + abs(h - a[j])) -    # print(dp) -print((dp[N - 1])) +n = int(eval(input())) +dp = [0] + [float("INF")] * (n) +h = list(map(int, input().split())) +for i in range(n): +    dp[i] = min( +        dp[i], dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]) +    ) +print((dp[n - 1]))