import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



N = int(eval(input()))

H = [int(x) for x in input().split()]



dp = [0] * N

dp[1] = abs(H[1]-H[0])

for i in range(2,N):

    dp[i] = min(dp[i-k] + abs(H[i]-H[i-k]) for k in [1,2])



answer = dp[-1]

print(answer)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N,*H = list(map(int,read().split()))



dp = [0]*N

for i in range(1,N):

    x = dp[i-1] + abs(H[i]-H[i-1])

    if i > 1:

        y = dp[i-2] + abs(H[i]-H[i-2])

        if x>y: x=y

    dp[i] = x



answer = dp[-1]

print(answer)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(eval(input()))
H = [int(x) for x in input().split()]
dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2])
answer = dp[-1]
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *H = list(map(int, read().split()))
dp = [0] * N
for i in range(1, N):
    x = dp[i - 1] + abs(H[i] - H[i - 1])
    if i > 1:
        y = dp[i - 2] + abs(H[i] - H[i - 2])
        if x > y:
            x = y
    dp[i] = x
answer = dp[-1]
print(answer)

-input = sys.stdin.readline -sys.setrecursionlimit(10**7) -N = int(eval(input())) -H = [int(x) for x in input().split()] +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +N, *H = list(map(int, read().split())) -dp[1] = abs(H[1] - H[0]) -for i in range(2, N): -    dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2]) +for i in range(1, N): +    x = dp[i - 1] + abs(H[i] - H[i - 1]) +    if i > 1: +        y = dp[i - 2] + abs(H[i] - H[i - 2]) +        if x > y: +            x = y +    dp[i] = x