Ejection of Bodies from the Solar System in the Course of the Accumulation of the Giant Planets and the Formation of the Cometary Cloud