Problem list
Log in
#r03216 · Online Judge > GoldOJ

High Card Wins

Silver II 2.0 s 256 MB

Cards $1 \dots 2N$ are split: Elsie holds the $N$ cards listed (one per round, in the given order) and Bessie holds the rest. In each round the higher card scores a point. Knowing Elsie's whole sequence, print the maximum number of points Bessie can score.

Input

Line 1: $N$ ($1 \le N \le 50000$). Next $N$ lines: Elsie's cards, one per line.

Output

Print Bessie's maximum score.

Example 1

Input
3
1
6
4
Output
2
Source
Online Judge > GoldOJ
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code