Studies of A and F stars in the region of the North Galactic Pole -- IV. A determination of the local mass density