It seems there is a discrepancy in the numbers provided. If Mary prepared 40 pineapple fruit yogurt cups, she cannot sell 58 cups, as she only had 40 available.
Please check the numbers again. If Mary sold all 40 cups, then she sold 40 cups. If this is meant to be a different scenario or story, please provide the correct figures.