N masses on an infinite string and related one-dimensional scattering problems