n = int(eval(input()))

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

cost = [None]*n

h1 = [None]*(n-1)

h2 = [None]*(n-2) 

one_ago = H[1]

two_ago = H[0]

h1[0] = abs(two_ago-one_ago)

for i in range(2, n):

    new = H[i]

    h1[i-1] = abs(one_ago-new)

    h2[i-2] = abs(two_ago-new)

    two_ago, one_ago = one_ago, new

cost[0], cost[1] = 0, h1[0]

for i in range(2, n):

    cost[i] = min(cost[i-2]+h2[i-2], cost[i-1]+h1[i-1])

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

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

dp = [None]*n

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

for i in range(2, n):

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

print((dp[-1]))
n = int(eval(input()))
H = list(map(int, input().split()))
cost = [None] * n
h1 = [None] * (n - 1)
h2 = [None] * (n - 2)
one_ago = H[1]
two_ago = H[0]
h1[0] = abs(two_ago - one_ago)
for i in range(2, n):
    new = H[i]
    h1[i - 1] = abs(one_ago - new)
    h2[i - 2] = abs(two_ago - new)
    two_ago, one_ago = one_ago, new
cost[0], cost[1] = 0, h1[0]
for i in range(2, n):
    cost[i] = min(cost[i - 2] + h2[i - 2], cost[i - 1] + h1[i - 1])
print((cost[n - 1]))

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

-H = list(map(int, input().split())) -cost = [None] * n -h1 = [None] * (n - 1) -h2 = [None] * (n - 2) -one_ago = H[1] -two_ago = H[0] -h1[0] = abs(two_ago - one_ago) +h = list(map(int, input().split())) +dp = [None] * n +dp[0], dp[1] = 0, abs(h[0] - h[1]) -    new = H[i] -    h1[i - 1] = abs(one_ago - new) -    h2[i - 2] = abs(two_ago - new) -    two_ago, one_ago = one_ago, new -cost[0], cost[1] = 0, h1[0] -for i in range(2, n): -    cost[i] = min(cost[i - 2] + h2[i - 2], cost[i - 1] + h1[i - 1]) -print((cost[n - 1])) +    dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i])) +print((dp[-1]))