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()))
print(h)

dp = []

for i in range(N):
	dp.append(float("inf"))

for i in range(N):
	if i ==0:
		dp[i] = 0
	else:
		dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
		if i > 1:
			dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])
N = int(input())
h = list(map(int,input().split()))

dp = []

for i in range(N):
	dp.append(float("inf"))
dp[0] = 0
for i in range(N):
	if not i+1 > N -1:
		dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
	if not i+2 > N -1:
		dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[-1])