Sum() function behaviour in constraint

In reply to imajeeth:

This has to do with the probability of picking a solution where arr[i]==d ? 2:1 is true. If you run more randomizations, or try a different tool, you get more varied results.