Counting problem (2) P17695


Statement
 

pdf   zip

Given a sequence of nn integer numbers x1xnx_1 \dots x_n, count how many ii’s, with 1in1 \le i \le n, follow the property

|{j:1jnxj<xi}|=i.\vert \{ j : 1 \le j \le n \wedge x_j < x_i \} \vert = i \enspace .

Input

The input consists of several cases. Each case begins with nn, followed by the nn integer numbers x1xnx_1 \dots x_n. Assume 0n1050 \le n \le 10^5.

Output

For each case, print the number of indices ii that fulfill the condition above.

Public test cases
  • Input

    4   2 3 5 7
    3   -7 -7 -7
    2   2 1
    

    Output

    0
    0
    1
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++