import sys



sys.setrecursionlimit(1000000)



N = int(eval(input()))

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



memo = [10**10 for _ in range(N+1)]



def dp(i):

    if i == 1:

        return 0

    elif i == 2:

        memo[i] = abs(h[i-2]-h[i-1])

        return memo[i]

    elif memo[i] < 10**10:

        return memo[i]

    else:

        memo[i] = min(

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

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

            dp(i-2) + abs(h[i-3]-h[i-2]) + abs(h[i-2]-h[i-1])

        )

        return memo[i]

print((dp(N)))
N = int(eval(input()))

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



memo = [-1 for _ in range(N+1)]



def dp(i):

    if i == 1:

        return 0

    elif i == 2:

        memo[i] = abs(h[i-2]-h[i-1])

        return memo[i]

    elif memo[i] >= 0:

        return memo[i]

    else:

        memo[i] = min(

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

            dp(i-2) + abs(h[i-3]-h[i-1])

        )

        return memo[i]



for i in range(1, N):

    dp(i)



print((dp(N)))
import sys

sys.setrecursionlimit(1000000)
N = int(eval(input()))
h = list(map(int, input().split()))
memo = [10**10 for _ in range(N + 1)]


def dp(i):
    if i == 1:
        return 0
    elif i == 2:
        memo[i] = abs(h[i - 2] - h[i - 1])
        return memo[i]
    elif memo[i] < 10**10:
        return memo[i]
    else:
        memo[i] = min(
            dp(i - 1) + abs(h[i - 2] - h[i - 1]),
            dp(i - 2) + abs(h[i - 3] - h[i - 1]),
            dp(i - 2) + abs(h[i - 3] - h[i - 2]) + abs(h[i - 2] - h[i - 1]),
        )
        return memo[i]


print((dp(N)))

N = int(eval(input()))
h = list(map(int, input().split()))
memo = [-1 for _ in range(N + 1)]


def dp(i):
    if i == 1:
        return 0
    elif i == 2:
        memo[i] = abs(h[i - 2] - h[i - 1])
        return memo[i]
    elif memo[i] >= 0:
        return memo[i]
    else:
        memo[i] = min(
            dp(i - 1) + abs(h[i - 2] - h[i - 1]), dp(i - 2) + abs(h[i - 3] - h[i - 1])
        )
        return memo[i]


for i in range(1, N):
    dp(i)
print((dp(N)))

-import sys - -sys.setrecursionlimit(1000000) -memo = [10**10 for _ in range(N + 1)] +memo = [-1 for _ in range(N + 1)] -    elif memo[i] < 10**10: +    elif memo[i] >= 0: -            dp(i - 1) + abs(h[i - 2] - h[i - 1]), -            dp(i - 2) + abs(h[i - 3] - h[i - 1]), -            dp(i - 2) + abs(h[i - 3] - h[i - 2]) + abs(h[i - 2] - h[i - 1]), +            dp(i - 1) + abs(h[i - 2] - h[i - 1]), dp(i - 2) + abs(h[i - 3] - h[i - 1]) +for i in range(1, N): +    dp(i)