n=int(eval(input()))

numbers = [int(n) for n in input().split()]

cost = []

for i in range(0,n):

    cost.append(0)

#cost[0]=0

cost[1]=abs(numbers[1]-numbers[0])

for i in range(2,n):

    cost[i]=min((cost[i-2]+abs(numbers[i]-numbers[i-2])),(cost[i-1]+abs(numbers[i]-numbers[i-1])))

    

#print(cost)

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

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

dp=[0]*(n+1)

dp[0]=0

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

for i in range(2,n):

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

  # print(dp)

print((dp[-2]))

n = int(eval(input()))
numbers = [int(n) for n in input().split()]
cost = []
for i in range(0, n):
    cost.append(0)
# cost[0]=0
cost[1] = abs(numbers[1] - numbers[0])
for i in range(2, n):
    cost[i] = min(
        (cost[i - 2] + abs(numbers[i] - numbers[i - 2])),
        (cost[i - 1] + abs(numbers[i] - numbers[i - 1])),
    )
# print(cost)
print((cost[n - 1]))

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

-numbers = [int(n) for n in input().split()] -cost = [] -for i in range(0, n): -    cost.append(0) -# cost[0]=0 -cost[1] = abs(numbers[1] - numbers[0]) +h = list(map(int, input().split())) +dp = [0] * (n + 1) +dp[0] = 0 +dp[1] = abs(h[1] - h[0]) -    cost[i] = min( -        (cost[i - 2] + abs(numbers[i] - numbers[i - 2])), -        (cost[i - 1] + abs(numbers[i] - numbers[i - 1])), -    ) -# print(cost) -print((cost[n - 1])) +    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])) +    # print(dp) +print((dp[-2]))