The number of charges is given as a parameter