Randomize dynamic array with constraint array.sum()

In reply to cgales:

Thank you for the answer, can you give me an example what you mean in the first option?