I’m not sure what you want to do but if i understood it well is as simple as change the last if statement to the next i show you:

I show you the output it display to check if it is correct:
And if you want to do it the amount of times of your array lenght you should remove the 2nd statement of your loop, like this:

