This is not the best way as you would need to have maxIndex - 1 in the loop to keep from using the unused index.
The best way is to start off the maxIndex number from -1.
That way your spell trigger still starts off with maxIndex = maxIndex + 1
Your loop will be from 0 to maxIndex
Your turn on condition for the loop trigger will be greater than -1.
Your turn off condition for the loop trigger will be less than 0.
You can do it but it doesn't really matter. If you have that many instances that you actually need the index at 0 then your thread will crash from hitting the op-limit long before you get all the indexes searched through.