Inserting the last element early isn't the worst, but better would be to create indices with the correct length in the first place (`2 + numberOfPartitions - 1`, I think).