Your 1st kudo for posting your solution!
But...
Why would you add the values and conditionally delete them?
Why not simply conditionally add them?
Less code, less CPU, less maintenance, easier to read...
And using Insert Into Array in stead of a Build Array is a rooky sign. Please don't (😓 traumatized).