The electronic distribution of an atom's electrons in the neutral or fundamental state is commonly performed with the Pauling diagram, shown below:

The detailed rules of this distribution can be found in the following two texts on our website: “Electronic distribution of electrons" and "Electronic Distribution Rules”.
The electronic distribution of ions works initially in the same way as for atoms in the neutral state; with only one difference. Since an ion is an atom that has gained or lost electrons, we must take this into account and do the following:

An important observation is: the change is made on the outermost sublevel and not the most energetic.
if the ion is a cation, we must remove the electrons that he lost. Let's look at an example:
The iron atom (atomic number = 26) has the following electronic distribution in the sublevels in energetic order: 1s2 2s2 2p6 3s2 3p6 4s2 3d6. As for the electronic layers, we have: K =2; L = 8; M = 14; N = 2.
This distribution is shown in the Pauling diagram below:

When the iron atom loses 2 electrons, it turns into the Fe cation.2+. So, when making your electronic distribution we have to remove 2 electrons from the last shell(N) and not from the most energetic sublevel, as shown below:

Thus, the electronic distribution of the Fe cation2+ is given by:
1s2 2s2 2p6 3s2 3p6 3d6 or K = 2; L = 8; M = 14

Now, if we have to perform the electronic distribution of a anion, we must add the electrons it received.See how this is done in the following example:
The sulfur anion (16s2-) is formed from the sulfur atom (16S) by the gain of 2 electrons, as indicated by charge 2-. Its ground state electronic distribution is given by:
1s2 2s2 2p6 3s2 3p4 or K = 2; L = 8; M = 6

In this case, the last sublevel is the same as the energy sublevel, 3p. So, we add to it the two electrons of the sulfur anion:
1s2 2s2 2p6 3s2 3p6 or K = 2; L = 8; M = 8

By Jennifer Fogaça
Graduated in Chemistry
Source: Brazil School - https://brasilescola.uol.com.br/quimica/distribuicao-eletronica-ions.htm