import sys



input = sys.stdin.readline





def main():

    N = int(eval(input()))

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



    dp = [0] * N

    dp[1] = abs(h[1] - h[0])

    h1 = list(map(abs, [h[i] - h[i - 1] for i in range(2, N)]))

    h2 = list(map(abs, [h[i] - h[i - 2] for i in range(2, N)]))

    for i in range(N - 2):

        a = dp[i] + h2[i]

        b = dp[i + 1] + h1[i]

        if a < b:

            dp[i + 2] = a

        else:

            dp[i + 2] = b



    ans = dp[-1]

    print(ans)





if __name__ == "__main__":

    main()

import sys



input = sys.stdin.readline





def main():

    N = int(eval(input()))

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



    dp = [0] * N

    dp[1] = abs(h[1] - h[0])

    for i in range(2, N):

        h2 = h[i] - h[i - 2]

        if h2 < 0:

            a = dp[i - 2] - h2

        else:

            a = dp[i - 2] + h2

        h1 = h[i] - h[i - 1]

        if h1 < 0:

            b = dp[i - 1] - h1

        else:

            b = dp[i - 1] + h1

        if a < b:

            dp[i] = a

        else:

            dp[i] = b



    ans = dp[-1]

    print(ans)





if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    h = list(map(int, input().split()))
    dp = [0] * N
    dp[1] = abs(h[1] - h[0])
    h1 = list(map(abs, [h[i] - h[i - 1] for i in range(2, N)]))
    h2 = list(map(abs, [h[i] - h[i - 2] for i in range(2, N)]))
    for i in range(N - 2):
        a = dp[i] + h2[i]
        b = dp[i + 1] + h1[i]
        if a < b:
            dp[i + 2] = a
        else:
            dp[i + 2] = b
    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    h = list(map(int, input().split()))
    dp = [0] * N
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        h2 = h[i] - h[i - 2]
        if h2 < 0:
            a = dp[i - 2] - h2
        else:
            a = dp[i - 2] + h2
        h1 = h[i] - h[i - 1]
        if h1 < 0:
            b = dp[i - 1] - h1
        else:
            b = dp[i - 1] + h1
        if a < b:
            dp[i] = a
        else:
            dp[i] = b
    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()

-    h1 = list(map(abs, [h[i] - h[i - 1] for i in range(2, N)])) -    h2 = list(map(abs, [h[i] - h[i - 2] for i in range(2, N)])) -    for i in range(N - 2): -        a = dp[i] + h2[i] -        b = dp[i + 1] + h1[i] +    for i in range(2, N): +        h2 = h[i] - h[i - 2] +        if h2 < 0: +            a = dp[i - 2] - h2 +        else: +            a = dp[i - 2] + h2 +        h1 = h[i] - h[i - 1] +        if h1 < 0: +            b = dp[i - 1] - h1 +        else: +            b = dp[i - 1] + h1 -            dp[i + 2] = a +            dp[i] = a -            dp[i + 2] = b +            dp[i] = b