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())
h = list(map(int,input().split()))
cost = [1000000]*(N+10)
cost[0] = 0
for i in range(N - 1):
  cost[i+1] = min(abs(h[i] - h[i+1]), cost[i+1])
  if i < N - 3:
    cost[i+2] = min(abs(h[i] - h[i+2]), cost[i+2])
print(cost[N-1])
N = int(input())
h = list(map(int,input().split()))
cost = [10**9]*N
cost[0] = 0
cost[1] = abs(h[1]-h[0])
for i in range(2, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])