Application of the Hellmann-Feynman theorem to the study of substitutional impurities in a linear chain of atoms