Problems
Frog
Frog
There are $n$ stones, numbered from $1$ to $n$. For each $i~(1 \le i \le n)$, the height of the $i$-th stone is $h_i$. The frog initially sits on stone $1$. It repeats the following action several times to reach stone $n$: if the frog is on stone $i$, it can jump either to stone $i + 1$ or to stone $i + 2$. The cost of moving from the $i$-th to the $j$-th stone is $|h_i − h_j|$.
Find the minimum cost of moving the frog to stone $n$.
\InputFile
The first line contains the number of stones $n~(2 \le n \le 10^5)$. The second line contains integers $h_1, h_2, ..., h_n~(1 \le h_i \le 10^4)$.
\OutputFile
Print the minimum cost of moving the frog to stone $n$.
\includegraphics{https://eolympusercontent.com/images/ksilg8i5l148bca9ks0cqvh9tk.gif}
Input example #1
4 10 30 40 20
Output example #1
30