💡 All Indices Problem

This is working fine on my local machine but not passing the test case

Your code is not producing correct output for following test case as,
Input : 3
5
5
5
Your output : 0 1
Expected Output : 0 1 2

Pls change your logic accordingly…