Electrons fill the lowest-energy sub-shells first to give the lowest-energy/ground-state configuration; this is why 1s fills before 2s and 2s fills before 2p; within a sub-shell containing several orbitals (such as 2p), electrons occupy separate orbitals singly before pairing/Hund's rule; this minimises inter-electron repulsion because two electrons in one orbital repel more strongly than two in separate orbitals; nitrogen has the configuration 1s²2s²2p³ with three singly occupied 2p orbitals (parallel spins); oxygen has the configuration 1s²2s²2p⁴, where one 2p orbital must contain a pair of electrons while the other two remain singly occupied