N = int(eval(input()))

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



# DP

inf = float("inf")

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

dp[0] = 0

for i in range(1, N):

    if 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]))
# Frog1

N = int(eval(input()))

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

inf = float("inf")

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

dp[0] = 0

for i in range(N):

    for j in (1, 2):

        if i + j >= N:

            continue

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

print((dp[-1]))
N = int(eval(input()))
h = list(map(int, input().split()))
# DP
inf = float("inf")
dp = [inf for _ in range(N)]
dp[0] = 0
for i in range(1, N):
    if 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]))

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

+# Frog1 -# DP -for i in range(1, N): -    if 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])) +for i in range(N): +    for j in (1, 2): +        if i + j >= N: +            continue +        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))