The Barbary macaque is gregarious, forming mixed groups of several females and males. Troops can have 10 to 100 individuals and are matriarchal, with their hierarchy determined by lineage to the lead female. Unlike other macaques, the males participate in rearing the young. Males may spend a considerable amount of time playing with and grooming infants. In this way, a strong social bond is formed between males and juveniles, both the male's own offspring and those of others in the troop. This may be a result of selectivity on the part of the females, who may prefer highly parental males.