Confusion about electron arrangement in elements
Basically, it depends on subshell. If you google something like &quot;subshells&quot;, you'll see that s-subshell can hold 2 electrons, p - 6, d - 10, f - 14, g - 18. It's very unlikely that you'll need subshells f and g, since you're school student.
Look at this picture (about Aufbau principle). 
It shows you the order of orbitals. Each s orbital holds up to 2 electrons, p - 6, so on. Fill them with all your electrons in given order.
For example, you have 12 electrons. The order (using Aufbau principle) is 1s-2s-2p-3s-3p-4s-3d...
1s holds 2 electrons (12-2 = 10), 2s holds 2 (10-2=8), 2p - 6 (8-6=2), 3 s - 2 (that's all). We see that 1st shell has 2, 2nd shell has 8, 3rd shell has 2, but 3rd is not full (since you still have empty 3p and 3d subshells).
So let's check. n is for number of shell. $2*n^2$ is for maximum number of electrons that shell can hold. For 1st, $2*1^2=2$, as we've seen. For 2nd, $2*2^2=8$, as we've seen. For 10th shell, the maximum is 200 electrons.
[edited]
Use Aufbau principle as well as info about subshells. Let's look at Y(39 electrons), which is in G3 P5. So we expect 5 shell to be outermost, and 3 valence electrons. Not &quot;electrons in outer shell&quot;, but valence. For school course of chemistry, outer shell electrons are usually referred to as &quot;valence&quot;, but these concepts are not always interchangeable.
Back to our example, Y has 1s-2electrons, 2s-2,2p-6,3s-2,3p-6,4s-2,3d-10,4p-6,5s-2,4d-1 (sum - 39). So yes, &quot;maximum shell&quot; is 5, as expected. But why do we have 1 electron on the outermost subshell, when we need to have 3? It's because valence electrons are those on 5s and 4d (2+1=3). Usually d subshell electrons are also considered &quot;valence&quot;, when you have 1-10 of them (if total number of electrons, starting with 4d electrons is 18 or less). I highly recommend you to use periodic table with 18 groups, it's much more convenient for these purposes.