Large deviations and quasipotential for finite state mean field interacting particle systems