Electromagnetic self-energy of quarks confined to a sphere