Formula For Total Distance