The following languages are only available languages for the problems from the contest

Kotlin Heroes: Episode 1:

- Kotlin 1.4.0

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
B. Bad Days

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputEvery day Kotlin heroes analyze the statistics of their website. For $$$n$$$ days, they wrote out $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of visits on the $$$i$$$-th day.

They believe that a day is bad if there are at least $$$2$$$ days before it with a strictly greater number of visits. For example, if $$$n=8$$$ and $$$a=[3, 1, 4, 1, 5, 9, 2, 6]$$$, then the day $$$4$$$ is bad (because $$$a_4=1$$$, but there are $$$a_1=3$$$ and $$$a_3=4$$$). Also, the day with the number $$$7$$$ is bad too.

Write a program that finds the number of bad days.

Input

The first line contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$), where $$$n$$$ is the number of days. The second line contains $$$n$$$ positive integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the number of website visits on the $$$i$$$-th day.

Output

Print the number of bad days, i.e. such days that there are at least two days before it with a strictly greater number of visits.

Examples

Input

8 3 1 4 1 5 9 2 6

Output

2

Input

5 1 1 1 1 1

Output

0

Input

13 2 7 1 8 2 8 1 8 2 8 4 5 9

Output

6

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/22/2021 05:30:01 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|