@staticmethod
def c():
    (n, *h) = map(int, sys.stdin.read().split())
    h = ([h[0]] + h)
    cost = ([None] * (n + 1))
    cost[0] = cost[1] = 0
    for i in range(2, (n + 1)):
        cost[i] = min((cost[(i - 2)] + abs((h[i] - h[(i - 2)]))), (cost[(i - 1)] + abs((h[i] - h[(i - 1)]))))
    print(cost[n])
@staticmethod
def c():
    (n, *h) = map(int, sys.stdin.read().split())
    h = ([h[0]] + h)
    cost = ([None] * (n + 1))
    cost[0] = cost[1] = 0
    for i in range(2, (n + 1)):
        cost[i] = min((cost[(i - 2)] + abs((h[i] - h[(i - 2)]))), (cost[(i - 1)] + abs((h[i] - h[(i - 1)]))))
    print(cost[n])