def main():

    N = int(eval(input()))

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



    h0 = 0

    h1 = abs(H[1] - H[0])



    for i in range(2, N):

        h0, h1 = h1, min(

            h0 + abs(H[i] - H[i - 2]),

            h1 + abs(H[i] - H[i - 1]))



    print(h1)





if __name__ == '__main__':

    main()
N=int(eval(input()))

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

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

h0=0

for i in range(1,N-1):

    h0,h1=h1,min(

    abs(h[i+1]-h[i-1])+h0,

    abs(h[i+1]-h[i])+h1

    )

print(h1)
def main():
    N = int(eval(input()))
    H = list(map(int, input().split()))
    h0 = 0
    h1 = abs(H[1] - H[0])
    for i in range(2, N):
        h0, h1 = h1, min(h0 + abs(H[i] - H[i - 2]), h1 + abs(H[i] - H[i - 1]))
    print(h1)


if __name__ == "__main__":
    main()

N = int(eval(input()))
h = list(map(int, input().split()))
h1 = abs(h[0] - h[1])
h0 = 0
for i in range(1, N - 1):
    h0, h1 = h1, min(abs(h[i + 1] - h[i - 1]) + h0, abs(h[i + 1] - h[i]) + h1)
print(h1)

-def main(): -    N = int(eval(input())) -    H = list(map(int, input().split())) -    h0 = 0 -    h1 = abs(H[1] - H[0]) -    for i in range(2, N): -        h0, h1 = h1, min(h0 + abs(H[i] - H[i - 2]), h1 + abs(H[i] - H[i - 1])) -    print(h1) - - -if __name__ == "__main__": -    main() +N = int(eval(input())) +h = list(map(int, input().split())) +h1 = abs(h[0] - h[1]) +h0 = 0 +for i in range(1, N - 1): +    h0, h1 = h1, min(abs(h[i + 1] - h[i - 1]) + h0, abs(h[i + 1] - h[i]) + h1) +print(h1)