#QHD0000001. Ếch 1 (Frog 1)

Ếch 1 (Frog 1)

Frog 1

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are NN stones with heights hih_i. A frog starts at stone 1 and may jump to stone i+1i+1 or i+2i+2. A jump from ii to jj costs ∣hi−hj∣|h_i-h_j|. Find the minimum total cost to reach stone NN.

Input

Line 1 contains NN. Line 2 contains NN integers h1,h2,…,hNh_1,h_2,\ldots,h_N.

Output

Print the minimum total cost.

Subtasks

  • Subtask 1 — 20 points: 2 <= N <= 20.
  • Subtask 2 — 30 points: 2 <= N <= 2000.
  • Subtask 3 — 50 points: 2 <= N <= 100000; 1 <= h_i <= 10000.

Examples

Input

4
10 30 40 20

Output

30

Explanation

An optimal route is 1→2→41\to2\to4, with cost ∣10−30∣+∣30−20∣=30|10-30|+|30-20|=30.