By a given array of animals, find the total number of legs