Hi and welcome to the forum. Your post was stuck in the moderation queue, but I have approved it. Please confirm your account with the email we sent so you can post freely in the future.
To answer your question, you might want to add a YSort node as a parent to all the red cubes. This will adjust the z-index automatically for you. Or if your level is small or needs special care, you can simply specify z-index values on each object, but in most cases YSort will be easier.