# EduDPA - Frog 1

def main():

    n = int(eval(input()))

    A = tuple(map(int, input().rstrip().split()))

    dp = [0, abs(A[1] - A[0])] + [float("inf")] * (n - 2)

    for i in range(2, n):

        dif1 = dp[i - 2] + abs(A[i] - A[i - 2])

        dif2 = dp[i - 1] + abs(A[i] - A[i - 1])

        dp[i] = min(dif1, dif2)

    print((dp[-1]))





if __name__ == "__main__":

    main()
# dpA - Frog 1

def main():

    n = int(eval(input()))

    A = tuple(map(int, input().rstrip().split()))

    x, y = 0, abs(A[1] - A[0])

    for i in range(2, n):

        dif1 = x + abs(A[i] - A[i - 2])

        dif2 = y + abs(A[i] - A[i - 1])

        x, y = y, min(dif1, dif2)

    print(y)





if __name__ == "__main__":

    main()
# EduDPA - Frog 1
def main():
    n = int(eval(input()))
    A = tuple(map(int, input().rstrip().split()))
    dp = [0, abs(A[1] - A[0])] + [float("inf")] * (n - 2)
    for i in range(2, n):
        dif1 = dp[i - 2] + abs(A[i] - A[i - 2])
        dif2 = dp[i - 1] + abs(A[i] - A[i - 1])
        dp[i] = min(dif1, dif2)
    print((dp[-1]))


if __name__ == "__main__":
    main()

# dpA - Frog 1
def main():
    n = int(eval(input()))
    A = tuple(map(int, input().rstrip().split()))
    x, y = 0, abs(A[1] - A[0])
    for i in range(2, n):
        dif1 = x + abs(A[i] - A[i - 2])
        dif2 = y + abs(A[i] - A[i - 1])
        x, y = y, min(dif1, dif2)
    print(y)


if __name__ == "__main__":
    main()

-# EduDPA - Frog 1 +# dpA - Frog 1 -    dp = [0, abs(A[1] - A[0])] + [float("inf")] * (n - 2) +    x, y = 0, abs(A[1] - A[0]) -        dif1 = dp[i - 2] + abs(A[i] - A[i - 2]) -        dif2 = dp[i - 1] + abs(A[i] - A[i - 1]) -        dp[i] = min(dif1, dif2) -    print((dp[-1])) +        dif1 = x + abs(A[i] - A[i - 2]) +        dif2 = y + abs(A[i] - A[i - 1]) +        x, y = y, min(dif1, dif2) +    print(y)