n = int(eval(input()))

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

dp = [10 ** 9 + 7 for i in range(100010)]

dp[0] = 0

for i in range(1,n):

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

  if i > 1:

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

print((dp[n-1]))

n = int(eval(input()))

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

INF = 10 ** 12



dp = [INF] * (n+1) # 初期化

dp[0] = 0 # 初期条件

for i in range(1,n):

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

  if i > 1:

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

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

n = int(eval(input()))
h = list(map(int, input().split()))
INF = 10**12
dp = [INF] * (n + 1)  # 初期化
dp[0] = 0  # 初期条件
for i in range(1, n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[n - 1]))

-dp = [10**9 + 7 for i in range(100010)] -dp[0] = 0 +INF = 10**12 +dp = [INF] * (n + 1)  # 初期化 +dp[0] = 0  # 初期条件