D. EverythingIsCake
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

EverythingIsCake has always believed that everything is cake. Naturally, this means that when he decides to build something, he builds a cake.

EverythingIsCake has constructed a cake consisting of $$$n$$$ layers stacked from bottom to top. The width of the $$$i$$$-th layer is $$$a_i$$$.

EverythingIsCake considers the cake stable if every layer is no wider than the layer directly below it. In other words, the sequence of layer widths must be non-increasing, so

$$$a_1 \ge a_2 \ge \cdots \ge a_n$$$.

Unfortunately, his cake may not currently be stable.

To fix it, EverythingIsCake may eat one contiguous range of layers. After those layers are removed, the layers above them fall down while preserving their relative order. He may also choose to eat no layers if the cake is already stable.

Find the minimum number of consecutive layers EverythingIsCake must eat so that the remaining cake is stable.

Input

The first line contains a single integer $$$n$$$ $$$(1 \le n \le 10^5)$$$, the number of layers in EverythingIsCake's cake.

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(1 \le a_i \le 10^9)$$$, where $$$a_i$$$ is the width of the $$$i$$$-th layer, listed from bottom to top.

Output

Output a single integer, the minimum number of consecutive layers EverythingIsCake must eat so that the remaining cake is stable.

Examples
Input
6
8 6 3 7 5 2
Output
2
Input
5
9 9 7 4 1
Output
0
Note

In the first test case, the answer is $$$2$$$. EverythingIsCake can eat the two layers with widths $$$3$$$ and $$$7$$$, leaving the cake with layer widths

$$$8, 6, 5, 2$$$.

This sequence is non-increasing, so the cake is stable. It is impossible to make the cake stable by eating only one layer.

In the second test case, the cake is already stable since

$$$9 \ge 9 \ge 7 \ge 4 \ge 1$$$.

Therefore, EverythingIsCake does not need to eat any layers, so the answer is $$$0$$$.