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.
N=int(input())
height_list=list(map(int,input().split()))
score_list=[ 0, abs(height_list[0]-height_list[1]) ]



for i in range(2,N):

    tmp=min(
        abs(height_list[i]-height_list[i-1])+score_list[i-1],
        abs(height_list[i]-height_list[i-2])+score_list[i-2]
    )

    score_list.append(tmp)

print(score_list)


N=int(input())
height_list=list(map(int,input().split()))
score_list=[ 0, abs(height_list[0]-height_list[1]) ]



for i in range(2,N):

    tmp=min(
        abs(height_list[i]-height_list[i-1])+score_list[i-1],
        abs(height_list[i]-height_list[i-2])+score_list[i-2]
    )

    score_list.append(tmp)

print(score_list[N-1])

