Explain the Problem Statement and Test Case 2

Can you please help me explain the problem statement and why the problem is failing at Test Case 2?

Hello @mrpareek, pls check this particular case
5
5 6 7 5 8
your code is giving an incorrect answer for this.
1 2 3 1 2 END
But it must be
1 2 3 1 5 END

Can you please explain how?

5
5 6 7 5 8
So when i = 0
we have 5 and the consecutive nos. including this and previous of this having value equal to a[i] and smaller than that is 1
now i = 1, a[i] = 6
now total values are 2 having values less than 6 and consecutive
now i = 2, a[i] = 7
now total values are 3 having values less than 7 and consecutive
now i = 3, a[i] = 5
now total values are 1 having values less than 1 and consecutive
now i = 4, a[i] = 8
now total values are 5 having values less than 8 and consecutive
so at last if we see all the values are less than 8 and values from i = 0 to i = 4 are in consecutive order