OpenKattis

#### Start

2020-03-18 16:00 AKDT

## Extrauppgifter [converted from problem group]

#### End

2021-03-18 16:00 AKDT
The end is near!
Session is over.
Not yet started.
Session is starting in -257 days 12:21:56

6180:21:56

2579:38:04

# Problem PFrosh Week

During Frosh Week, students play various fun games to get to know each other and compete against other teams. In one such game, all the frosh on a team stand in a line, and are then asked to arrange themselves according to some criterion, such as their height, their birth date, or their student number. This rearrangement of the line must be accomplished only by successively swapping pairs of consecutive students. The team that finishes fastest wins. Thus, in order to win, you would like to minimize the number of swaps required.

## Input

The first line of input contains one positive integer $n$, the number of students on the team, which will be no more than one million. The following $n$ lines each contain one integer between $1$ and $10^9$ (inclusive), the student number of each student on the team. No student number will appear more than once.

## Output

Output a line containing the minimum number of swaps required to arrange the students in increasing order by student number.

Sample Input 1 Sample Output 1
3
3
1
2

2