Tensor correlations and evolution of single-particle energies in medium-mass nuclei