Consider a small dataset representing the ages of six participants in a research study:
Ages: 25, 30, 22, 29, 27, 31
Calculate the median age of the participants.