There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i.  There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N:    * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on.  Find the minimum possible total cost incurred before the frog reaches Stone N.
# coding: utf-8
# Your code here!
N=int(input())
li=list(map(int,input().split()))
kekka=[0]*N
cost=0
kekka[0]=li[0]
#print(cost)
#print(li)
for i in range(1,N):
    if i ==1:
        kekka[i]=abs(li[1]-li[0])
    else:
        a=abs(li[i-2]-li[i])
        b=abs(li[i-1]-li[i])
        if a>b:
            kekka[i]=b+kekka[i-1]
        else:
            kekka[i]=a+kekka[i-2]


print(kekka[-1]-kekka[i])
N=int(input())
li=list(map(int,input().split()))
kekka=[0]*N
#print(li)

for i in range(1,N):
    if i==1:
        kekka[i]=abs(li[i]-li[i-1])
    else:
        a=abs(li[i]-li[i-1])+kekka[i-1]
        b=abs(li[i]-li[i-2])+kekka[i-2]
        kekka[i]=min(a,b)
print(kekka[-1])