# coding: utf-8

N=int(eval(input()))

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

def dp(L):

    dp=[0]*N

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

    for i in range(N-2):

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

    return dp[N-1]

    

print((dp(H)))
# coding: utf-8

n = int(eval(input()))

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

dp = [0] * n

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

for i in range(2, n):

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

print((dp[n-1]))
# coding: utf-8
N = int(eval(input()))
H = list(map(int, input().split()))


def dp(L):
    dp = [0] * N
    dp[1] = abs(L[1] - L[0])
    for i in range(N - 2):
        dp[i + 2] = min(
            dp[i] + abs(L[i + 2] - L[i]), dp[i + 1] + abs(L[i + 2] - L[i + 1])
        )
    return dp[N - 1]


print((dp(H)))

# coding: utf-8
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[n - 1]))

-N = int(eval(input())) -H = list(map(int, input().split())) - - -def dp(L): -    dp = [0] * N -    dp[1] = abs(L[1] - L[0]) -    for i in range(N - 2): -        dp[i + 2] = min( -            dp[i] + abs(L[i + 2] - L[i]), dp[i + 1] + abs(L[i + 2] - L[i + 1]) -        ) -    return dp[N - 1] - - -print((dp(H))) +n = int(eval(input())) +h = list(map(int, input().split())) +dp = [0] * n +dp[1] = abs(h[0] - h[1]) +for i in range(2, n): +    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) +print((dp[n - 1]))