So one important aspect of electron configuration must be understood. Electron configuration doesn't necessarily have to order things from lowest energy to highest energy. Although that's usually the case, that doesn't have to happen. In other words, let's look at the following important facts. So four S that energy level is at a lower energy than three D, and five S is at a lower energy level than four D.
And this holds for six S and 5D as well. Now, these things you just have to simply remember.