Dan to Beersheba
This phrase uses two place names Dan, in the far north, and Beersheba, in the far south, to represent the entire country.
count all the people ... fit for battle
This means to count all the men except those men who are either too young, too old, or physically unable to fight.