find min and max values in sequence