A median redshift of 2.4 for galaxies bright at submillimetre wavelengths