It looks like there may be an error in the numbers provided. Mary prepared 40 yogurt cups, but you mentioned that she sold 58 cups, which exceeds the number she initially prepared.
If Mary prepared 40 cups, then the maximum number of cups she could have sold is 40.
Please check the numbers and let me know if you need help with something else!