cswork / OAOpen practice workspace

ZipRecruiterOA #13

Time Travel

Estimated EasyJudge-ready

Topics (AI-labelled)In-place ArraysSimulation

Visit a list of years in the given order. Moving between equal adjacent years costs 0; going to a later year costs 1; going back to an earlier year costs 2. Find the total time.

Input

The first line contains n (1..100); the second line contains n years (1..10000).

Output

Output the total time.

Example 1

Input:

4
2000 1990 2005 2050

Output:

4

Example 2

Input:

3
2000 2021 2005

Output:

3

Example 3

Input:

3
2021 2021 2005

Output:

2

Editorial

Loading solution…