a = int(eval(input()))

b = 2+1#int(input())

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

dp = [0]+[10**10]*(a-1)

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

for i,h in enumerate(x):

    for j in range(i+1,min(i+b,a)):

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

#print(dp)

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

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

inf = float('INF')

dp = [inf]*n

dp[0] = 0

for i in range(1,n):

    if i != 1:dp[i]=min(dp[i],dp[i-2]+abs(H[i]-H[i-2]))



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



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

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

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