Getting the positions of min and max values in a list