When we try to predict electronic configurations by the building up principle we add electrons to the d-orbitals before the p-orbitals for principal quantum numbers n ≥ 4. What I don't understand is why, according to my textbook, we're supposed to remove electrons from np-orbitals first, then ns-orbitals and then (n-1)d-orbitals when predicting the configuration for cations. Why do we add electrons to (n-1)d-orbitals after ns-orbitals but remove electrons from ns-orbitals before (n-1)d-orbitals? - makes no sense. Furthermore, if someone could explain or point me somewhere to an explanation as to how the energy levels are calculated (why E((n-1)d) > E(ns) for n ≥ 4) that would be great.