You are given an array of positive integers beans, where each integer represents the number of magic beans contained in a bag.
You want to remove beans from the bags such that every remaining non empty bag contains the exact same number of magic beans. You can remove any number of beans from any bag, including emptying it completely, but you cannot add beans to any bag.
Return the minimum total number of magic beans that must be removed.
Constraints:
beans.length
beans[i]
You are given an array of positive integers beans, where each integer represents the number of magic beans contained in a bag.
You want to remove beans from the bags such that every remaining non empty bag contains the exact same number of magic beans. You can remove any number of beans from any bag, including emptying it completely, but you cannot add beans to any bag.
Return the minimum total number of magic beans that must be removed.
Constraints:
beans.length
beans[i]