INF = 10 ** 10



N = int(eval(input()))

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



dp = [INF for _ in range(N)]

dp[0] = 0

# 0-indexed



for i in range(1, N):

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

    if i - 2 >= 0:

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



print((dp[N - 1]))

INF = float('inf')



N = int(eval(input()))

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

h = [0] + h



dp = [INF for i in range(N + 1)]

# 1-indexed, 1 -> N

dp[1] = 0



for i in range(2, N + 1):

    if i > 2:

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

    else:

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

print((dp[N]))

INF = 10**10
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [INF for _ in range(N)]
dp[0] = 0
# 0-indexed
for i in range(1, N):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i - 2 >= 0:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[N - 1]))

INF = float("inf")
N = int(eval(input()))
h = list(map(int, input().split()))
h = [0] + h
dp = [INF for i in range(N + 1)]
# 1-indexed, 1 -> N
dp[1] = 0
for i in range(2, N + 1):
    if i > 2:
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
    else:
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
print((dp[N]))

-INF = 10**10 +INF = float("inf") -dp = [INF for _ in range(N)] -dp[0] = 0 -# 0-indexed -for i in range(1, N): -    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) -    if i - 2 >= 0: -        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) -print((dp[N - 1])) +h = [0] + h +dp = [INF for i in range(N + 1)] +# 1-indexed, 1 -> N +dp[1] = 0 +for i in range(2, N + 1): +    if i > 2: +        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) +    else: +        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]) +print((dp[N]))