n = int(eval(input()))

hs = tuple(map(int, input().split()))



a, b = 0, abs(hs[1] - hs[0])



for i in range(2, n):

  c = hs[i]

  a, b = b, min(a + abs(c - hs[i-2]), b + abs(c - hs[i-1]))



print(b)

def main():

    n = int(eval(input()))

    hs = tuple(map(int, input().split()))

    

    a, b = 0, abs(hs[1] - hs[0])

    

    for i in range(2, n):

        c = hs[i]

        a, b = b, min(a + abs(c - hs[i-2]), b + abs(c - hs[i-1]))

    

    print(b)



if __name__ == "__main__":

    main()
n = int(eval(input()))
hs = tuple(map(int, input().split()))
a, b = 0, abs(hs[1] - hs[0])
for i in range(2, n):
    c = hs[i]
    a, b = b, min(a + abs(c - hs[i - 2]), b + abs(c - hs[i - 1]))
print(b)

def main():
    n = int(eval(input()))
    hs = tuple(map(int, input().split()))
    a, b = 0, abs(hs[1] - hs[0])
    for i in range(2, n):
        c = hs[i]
        a, b = b, min(a + abs(c - hs[i - 2]), b + abs(c - hs[i - 1]))
    print(b)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -hs = tuple(map(int, input().split())) -a, b = 0, abs(hs[1] - hs[0]) -for i in range(2, n): -    c = hs[i] -    a, b = b, min(a + abs(c - hs[i - 2]), b + abs(c - hs[i - 1])) -print(b) +def main(): +    n = int(eval(input())) +    hs = tuple(map(int, input().split())) +    a, b = 0, abs(hs[1] - hs[0]) +    for i in range(2, n): +        c = hs[i] +        a, b = b, min(a + abs(c - hs[i - 2]), b + abs(c - hs[i - 1])) +    print(b) + + +if __name__ == "__main__": +    main()