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

INF = 1 << 60
dp = [INF for _ in range(N)]


def solve(i):
    if dp[i] < INF:
        return dp[i]
    if i == 0:
        return 0
    cost = INF
    cost = min(cost, solve(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        cost = min(cost, solve(i - 2) + abs(h[i] - h[i - 2]))
    return cost


print(solve(N - 1))
