# -*- coding: utf-8 -*-

"""

Created on Tue Mar  5 15:34:44 2019



@author: avina

"""



n = int(eval(input()))

L = list(map(int, input().strip().split()))

dp = [0 for i in range(n)]

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

for j in range(2,n):

    for i in range(j,j+2):

        if i < n:

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



print((dp[-1]))
# -*- coding: utf-8 -*-

"""

Created on Tue Oct  8 08:28:30 2019



@author: avina

"""



n = int(eval(input()))

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

dp= [0]*n



for i in range(1,n):

    b = 1e6

    a = dp[i-1] + abs(l[i] - l[i-1])

    if i -2 >-1:

        b = dp[i-2] + abs(l[i] - l[i-2])

    dp[i] = min(a,b)    

print((dp[-1]))
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  5 15:34:44 2019
@author: avina
"""
n = int(eval(input()))
L = list(map(int, input().strip().split()))
dp = [0 for i in range(n)]
dp[1] = abs(L[1] - L[0])
for j in range(2, n):
    for i in range(j, j + 2):
        if i < n:
            dp[i] = min(
                dp[i - 2] + abs(L[i] - L[i - 2]), dp[i - 1] + abs(L[i] - L[i - 1])
            )
print((dp[-1]))

# -*- coding: utf-8 -*-
"""
Created on Tue Oct  8 08:28:30 2019
@author: avina
"""
n = int(eval(input()))
l = list(map(int, input().split()))
dp = [0] * n
for i in range(1, n):
    b = 1e6
    a = dp[i - 1] + abs(l[i] - l[i - 1])
    if i - 2 > -1:
        b = dp[i - 2] + abs(l[i] - l[i - 2])
    dp[i] = min(a, b)
print((dp[-1]))

-Created on Tue Mar  5 15:34:44 2019 +Created on Tue Oct  8 08:28:30 2019 -L = list(map(int, input().strip().split())) -dp = [0 for i in range(n)] -dp[1] = abs(L[1] - L[0]) -for j in range(2, n): -    for i in range(j, j + 2): -        if i < n: -            dp[i] = min( -                dp[i - 2] + abs(L[i] - L[i - 2]), dp[i - 1] + abs(L[i] - L[i - 1]) -            ) +l = list(map(int, input().split())) +dp = [0] * n +for i in range(1, n): +    b = 1e6 +    a = dp[i - 1] + abs(l[i] - l[i - 1]) +    if i - 2 > -1: +        b = dp[i - 2] + abs(l[i] - l[i - 2]) +    dp[i] = min(a, b)