Mass function of dormant black holes and the evolution of active galactic nuclei