n=int(eval(input()))

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

min_cost=[0]*n

min_cost[0]=0

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

for i in range(2,n):

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

print((min_cost[-1]))
#dp-a

n=int(eval(input()))

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

dp=[0]*n

for i in range(n):

    if i==0:dp[0]=0

    elif i==1:dp[1]=abs(h[0]-h[1])

    else:

        dp[i]=min(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()))
h = list(map(int, input().split()))
min_cost = [0] * n
min_cost[0] = 0
min_cost[1] = abs(h[1] - h[0])
for i in range(2, n):
    min_cost[i] = min(
        min_cost[i - 1] + abs(h[i] - h[i - 1]), min_cost[i - 2] + abs(h[i] - h[i - 2])
    )
print((min_cost[-1]))

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

+# dp-a -min_cost = [0] * n -min_cost[0] = 0 -min_cost[1] = abs(h[1] - h[0]) -for i in range(2, n): -    min_cost[i] = min( -        min_cost[i - 1] + abs(h[i] - h[i - 1]), min_cost[i - 2] + abs(h[i] - h[i - 2]) -    ) -print((min_cost[-1])) +dp = [0] * n +for i in range(n): +    if i == 0: +        dp[0] = 0 +    elif i == 1: +        dp[1] = abs(h[0] - h[1]) +    else: +        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])) +print((dp[n - 1]))