I understand that we need to supply energy to counter the nuclear attraction when we remove electrons and that is the reason ionization energy is endothermic. However, why does an atom release energy when we add an electron to it? And also why do some elements( like the halogens) release more energy than the rest? I can understand that it is easier for them to gain electrons than the others because of small size and increase in nuclear charge and I guess it just goes to the first question again. Please help.