LearnPy Hub
← Arena
AdvancedRating 1700

Jumps With Teleports

From index i you can step to i − 1 or i + 1, or teleport to any index j holding the same value. Print the fewest moves from the first index to the last.

Input

n, then n integers.

Output

One integer.

Sample 1

Input
10
100 -23 -23 404 100 23 23 23 3 404
Output
3

Sample 2

Input
1
7
Output
0
solution.py
Output appears here
Jumps With Teleports · Python Arena problem · LearnPy Hub