The arrangement of the electrons on the orbitals is governed by the principles of quantum energy. To be able to draw the correct electronic configuration of an element, they should follow these three principles.
1. Aufbau's Principle. The electrons of an element should be filled up from the highest energy level. You can use the periodic table as a guide for this. In decreasing order, the energy of the orbitals are 1s, 2s, 2p, 3s, 3p, 4s, 3d, 4p, 5s, 4d, 5p, 6s, 4f, 5d, 6p, 7s, 5f, 6d and 7p. Each 'box' of these orbital must be filled with two electrons from 1s before moving on to the next.
2. Hund's rule. This states that you must fill all boxes of one orbital with one electron first. For example, 2p has 3 boxes. You fill one electron for each box first before going back to fill it to two electrons if there are still excess.
3. Pauli's Exclusion Principle. This states that no electrons of the same element should have the same quantum numbers. To achieve this, the two electrons in each box should have opposite spins, one facing up, and the other facing down.
Using these three rules, you will be able to draw the electronic configuration of Fluorine with 9 electrons as shown in the picture.