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())
nums = list(map(int, input().split(" ")))
def frog(n, nums):
    if n == 0:
        return 0
    if n == 1:
        return nums[0]
    cost = [0, nums[0]]
    for i in range(2, len(nums)):
        cost.append(cost[i-2] + min(abs(nums[i-2] - nums[i]), abs(nums[i-1] - nums[i])))
    return cost[n - 1]
print(frog(n, nums))
n = int(input())
nums = list(map(int, input().split(" ")))
def frog(n, nums):
    cost = [0, abs(nums[1] - nums[0])]
    for i in range(2, len(nums)):
        cost.append(min(cost[i-2] + abs(nums[i-2] - nums[i]), cost[i-1] + abs(nums[i-1] - nums[i])))
    return cost[n - 1]
print(frog(n, nums))