get the max and min of list