SDE Path

Frog Jump Problem

Easy

Frog Jump Problem

Given heights of stones, find the minimum cost for a frog to reach the last stone, jumping 1 or 2 steps.

Input format

The first line contains N. The second line contains N heights (0–100).

Output format

Print minimum cost to jump 0→N−1, where cost |h[i]−h[j]| and jumps are ±1 or ±2 steps.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
4
10 30 40 20
Expected output
30
Example 2
Input
3
10 20 30
Expected output
20