# 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()
# dpA - Frog 1

"""

Example:

x y

  x y

    x y ...

        x y (y: answer)

"""

def main():

    n = int(eval(input()))

    A = tuple(map(int, input().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 = dif1 if dif1 <= dif2 else dif2

    print(y)





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()

# dpA - Frog 1
"""
Example:
x y
  x y
    x y ...
        x y (y: answer)
"""


def main():
    n = int(eval(input()))
    A = tuple(map(int, input().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 = dif1 if dif1 <= dif2 else dif2
    print(y)


if __name__ == "__main__":
    main()

+""" +Example: +x y +  x y +    x y ... +        x y (y: answer) +""" + + -    A = tuple(map(int, input().rstrip().split())) +    A = tuple(map(int, input().split())) -        x, y = y, min(dif1, dif2) +        x = y +        y = dif1 if dif1 <= dif2 else dif2