Chemical separation in horizontal-branch stars