Implement median.