import sys

import io



f = sys.stdin.buffer

n = int(f.readline())

h = list(map(int, f.readline().split()))

p0, p1 = 0, abs(h[1] - h[0])

for i in range(2, n):

    p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))

    p0, p1 = p1, p2

print(p1)

import sys

import io





def main():

    f = sys.stdin.buffer

    n = int(f.readline())

    h = list(map(int, f.readline().split()))

    p0, p1 = 0, abs(h[1] - h[0])

    for i in range(2, n):

        p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))

        p0, p1 = p1, p2

    print(p1)





if __name__ == "__main__":

    main()

import sys
import io

f = sys.stdin.buffer
n = int(f.readline())
h = list(map(int, f.readline().split()))
p0, p1 = 0, abs(h[1] - h[0])
for i in range(2, n):
    p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))
    p0, p1 = p1, p2
print(p1)

import sys
import io


def main():
    f = sys.stdin.buffer
    n = int(f.readline())
    h = list(map(int, f.readline().split()))
    p0, p1 = 0, abs(h[1] - h[0])
    for i in range(2, n):
        p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))
        p0, p1 = p1, p2
    print(p1)


if __name__ == "__main__":
    main()

-f = sys.stdin.buffer -n = int(f.readline()) -h = list(map(int, f.readline().split())) -p0, p1 = 0, abs(h[1] - h[0]) -for i in range(2, n): -    p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2])) -    p0, p1 = p1, p2 -print(p1) + +def main(): +    f = sys.stdin.buffer +    n = int(f.readline()) +    h = list(map(int, f.readline().split())) +    p0, p1 = 0, abs(h[1] - h[0]) +    for i in range(2, n): +        p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2])) +        p0, p1 = p1, p2 +    print(p1) + + +if __name__ == "__main__": +    main()