n=int(eval(input()))

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

dp=[10**9]*(n)

dp[0]=0

for i in range(1,n):

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

    if i==1:

        continue

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

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

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

dp=[float('inf')]*n

dp[0]=0

for i in range(1,n):

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

    if i==1:

        continue

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

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

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

-dp = [10**9] * (n) +dp = [float("inf")] * n -print((dp[n - 1])) +print((dp[-1]))