N = int(eval(input()))

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



dp = [0]*N



for i, x in enumerate(H):

  if i == 0:

    continue

  elif i == 1:

    dp[i] = abs(H[i]-H[i-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[-1]))
N = int(eval(input()))

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



dp = [0]



for i, x in enumerate(H):

  if i == 0:

    continue

  elif i == 1:

    dp.append( abs(H[i] - H[i-1]) )

  else:

    dp.append( min( dp[i-2] + abs(H[i] - H[i-2]) , dp[i-1] + abs(H[i] - H[i-1]) ) )



print((dp[-1]))
N = int(eval(input()))
H = list(map(int, input().split()))
dp = [0] * N
for i, x in enumerate(H):
    if i == 0:
        continue
    elif i == 1:
        dp[i] = abs(H[i] - H[i - 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[-1]))

N = int(eval(input()))
H = list(map(int, input().split()))
dp = [0]
for i, x in enumerate(H):
    if i == 0:
        continue
    elif i == 1:
        dp.append(abs(H[i] - H[i - 1]))
    else:
        dp.append(
            min(dp[i - 2] + abs(H[i] - H[i - 2]), dp[i - 1] + abs(H[i] - H[i - 1]))
        )
print((dp[-1]))

-dp = [0] * N +dp = [0] -        dp[i] = abs(H[i] - H[i - 1]) +        dp.append(abs(H[i] - H[i - 1])) -        dp[i] = min(dp[i - 2] + abs(H[i] - H[i - 2]), dp[i - 1] + abs(H[i] - H[i - 1])) +        dp.append( +            min(dp[i - 2] + abs(H[i] - H[i - 2]), dp[i - 1] + abs(H[i] - H[i - 1])) +        )