import sys

sys.setrecursionlimit(100000)

input=lambda : sys.stdin.readline().rstrip('\n')



n=int(eval(input()))

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



dp=[10**18 for i in range(n)]

def cost(n):

    if n==0:

        return 0

    if n<0:

        return 10**18

    if dp[n]!=10**18:

        return dp[n]

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

    return dp[n]



print((cost(n-1)))

import sys

sys.setrecursionlimit(2000000000)

input=lambda : sys.stdin.readline().rstrip('\n')



n=int(eval(input()))

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



dp=[10**18 for i in range(n)]

def cost(n):

    if n==0:

        return 0

    if n<0:

        return 10**18

    if dp[n]!=10**18:

        return dp[n]

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

    return dp[n]



print((cost(n-1)))

import sys

sys.setrecursionlimit(100000)
input = lambda: sys.stdin.readline().rstrip("\n")
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [10**18 for i in range(n)]


def cost(n):
    if n == 0:
        return 0
    if n < 0:
        return 10**18
    if dp[n] != 10**18:
        return dp[n]
    dp[n] = min(cost(n - 1) + abs(h[n] - h[n - 1]), cost(n - 2) + abs(h[n] - h[n - 2]))
    return dp[n]


print((cost(n - 1)))

import sys

sys.setrecursionlimit(2000000000)
input = lambda: sys.stdin.readline().rstrip("\n")
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [10**18 for i in range(n)]


def cost(n):
    if n == 0:
        return 0
    if n < 0:
        return 10**18
    if dp[n] != 10**18:
        return dp[n]
    dp[n] = min(cost(n - 1) + abs(h[n] - h[n - 1]), cost(n - 2) + abs(h[n] - h[n - 2]))
    return dp[n]


print((cost(n - 1)))

-sys.setrecursionlimit(100000) +sys.setrecursionlimit(2000000000)