How sex affects mental health