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

"""

Created on Sat May  2 00:21:08 2020



@author: Kanaru Sato

"""

import sys

sys.setrecursionlimit(10 ** 6)



N = int(eval(input()))

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

memo = [-1]*N

memo[0] = 0

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



#topdown

def cost(n):

    if n <= 1 or memo[n] >= 0:

        return memo[n]

    else:

        memo[n] = min(cost(n-2)+abs(h[n]-h[n-2]),cost(n-1)+abs(h[n]-h[n-1]))

        return memo[n]



print((cost(N-1)))
# -*- coding: utf-8 -*-

"""

Created on Sat May  2 18:45:39 2020



@author: Kanaru Sato

"""



n = int(eval(input()))

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



dp = [-1]*n



for i in range(n):

    if i == 0:

        dp[i] = 0

    elif i == 1:

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

    else:

        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 -*-
"""
Created on Sat May  2 00:21:08 2020
@author: Kanaru Sato
"""
import sys

sys.setrecursionlimit(10**6)
N = int(eval(input()))
h = list(map(int, input().split()))
memo = [-1] * N
memo[0] = 0
memo[1] = abs(h[1] - h[0])
# topdown
def cost(n):
    if n <= 1 or memo[n] >= 0:
        return memo[n]
    else:
        memo[n] = min(
            cost(n - 2) + abs(h[n] - h[n - 2]), cost(n - 1) + abs(h[n] - h[n - 1])
        )
        return memo[n]


print((cost(N - 1)))

# -*- coding: utf-8 -*-
"""
Created on Sat May  2 18:45:39 2020
@author: Kanaru Sato
"""
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [-1] * n
for i in range(n):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = abs(h[1] - h[0])
    else:
        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]))

-Created on Sat May  2 00:21:08 2020 +Created on Sat May  2 18:45:39 2020 -import sys - -sys.setrecursionlimit(10**6) -N = int(eval(input())) +n = int(eval(input())) -memo = [-1] * N -memo[0] = 0 -memo[1] = abs(h[1] - h[0]) -# topdown -def cost(n): -    if n <= 1 or memo[n] >= 0: -        return memo[n] +dp = [-1] * n +for i in range(n): +    if i == 0: +        dp[i] = 0 +    elif i == 1: +        dp[i] = abs(h[1] - h[0]) -        memo[n] = min( -            cost(n - 2) + abs(h[n] - h[n - 2]), cost(n - 1) + abs(h[n] - h[n - 1]) -        ) -        return memo[n] - - -print((cost(N - 1))) +        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]))