To solve this, first write an equation showing what is happening to each of the elements. Then look at the coefficients to determine the moles of electrons per mole of ion.
Mg = Mg^+2 + 2 e^-1 this means that when magnesium is oxidized it loses two moles of electrons for every mole of magnesium you started with.
K = K^+1 + 1 e^-1 or one mole of electrons produced per mole of potassium ion formed
Al = Al^+3 + 3 e^-1 or three moles of electrons produced per mole of aluminum ion formed
O + 2 e^-1 = O^-2 It takes two moles of electrons to form one mole of oxygen ion.