##https://atcoder.jp/contests/dp/tasks/dp_a



N = int(eval(input()))

##N, M = map(int, input().split())



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

F = [0]*N#それぞれに対する回答を格納する箇所

C = [0]*N#Nに飛ぶ時の最小コストの格納



F[0] = 1

F[1] = 1

C[0] = 0

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



for i in range(2, N):

    if C[i-2] + abs(H[i] - H[i-2]) > C[i-1] + abs(H[i] - H[i-1]):

        F[i] = F[i-1]

        C[i] = C[i-1] + abs(H[i] - H[i-1])

    elif C[i-2] + abs(H[i] - H[i-2]) < C[i-1] + abs(H[i] - H[i-1]):

        F[i] = F[i-2]

        C[i] = C[i-2] + abs(H[i] - H[i-2])

    else:

        F[i] = F[i-2] + F[i-1]

        C[i] = C[i-2] + abs(H[i] - H[i-2])        

print((C[N-1]))

##https://atcoder.jp/contests/dp/tasks/dp_a



N = int(eval(input()))

##N, M = map(int, input().split())



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

C = [0]*N#Nに飛ぶ時の最小コストの格納





C[0] = 0

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



for i in range(2, N):

    if C[i-2] + abs(H[i] - H[i-2]) > C[i-1] + abs(H[i] - H[i-1]):

        C[i] = C[i-1] + abs(H[i] - H[i-1])

    elif C[i-2] + abs(H[i] - H[i-2]) < C[i-1] + abs(H[i] - H[i-1]):

        C[i] = C[i-2] + abs(H[i] - H[i-2])

    else:

        C[i] = C[i-2] + abs(H[i] - H[i-2])        

print((C[N-1]))

##https://atcoder.jp/contests/dp/tasks/dp_a
N = int(eval(input()))
##N, M = map(int, input().split())
H = list(map(int, input().split()))
F = [0] * N  # それぞれに対する回答を格納する箇所
C = [0] * N  # Nに飛ぶ時の最小コストの格納
F[0] = 1
F[1] = 1
C[0] = 0
C[1] = abs(H[0] - H[1])
for i in range(2, N):
    if C[i - 2] + abs(H[i] - H[i - 2]) > C[i - 1] + abs(H[i] - H[i - 1]):
        F[i] = F[i - 1]
        C[i] = C[i - 1] + abs(H[i] - H[i - 1])
    elif C[i - 2] + abs(H[i] - H[i - 2]) < C[i - 1] + abs(H[i] - H[i - 1]):
        F[i] = F[i - 2]
        C[i] = C[i - 2] + abs(H[i] - H[i - 2])
    else:
        F[i] = F[i - 2] + F[i - 1]
        C[i] = C[i - 2] + abs(H[i] - H[i - 2])
print((C[N - 1]))

##https://atcoder.jp/contests/dp/tasks/dp_a
N = int(eval(input()))
##N, M = map(int, input().split())
H = list(map(int, input().split()))
C = [0] * N  # Nに飛ぶ時の最小コストの格納
C[0] = 0
C[1] = abs(H[0] - H[1])
for i in range(2, N):
    if C[i - 2] + abs(H[i] - H[i - 2]) > C[i - 1] + abs(H[i] - H[i - 1]):
        C[i] = C[i - 1] + abs(H[i] - H[i - 1])
    elif C[i - 2] + abs(H[i] - H[i - 2]) < C[i - 1] + abs(H[i] - H[i - 1]):
        C[i] = C[i - 2] + abs(H[i] - H[i - 2])
    else:
        C[i] = C[i - 2] + abs(H[i] - H[i - 2])
print((C[N - 1]))

-F = [0] * N  # それぞれに対する回答を格納する箇所 -F[0] = 1 -F[1] = 1 -        F[i] = F[i - 1] -        F[i] = F[i - 2] -        F[i] = F[i - 2] + F[i - 1]