Sum() function behaviour in constraint

In reply to dave_59:

Hi Dave,

I see the following output from your code.
d = 6, arr = '{'h6, 'ha, 'h4, 'h7, 'h2, 'h6, 'h1, 'h3, 'h9, 'h8} sum = 56
d = 2, arr = '{'h9, 'h6, 'h2, 'h2, 'h3, 'ha, 'h7, 'h4, 'h5, 'h8} sum = 56
d = 6, arr = '{'h6, 'h3, 'h5, 'h9, 'h6, 'ha, 'h2, 'h8, 'h7, 'h4} sum = 60
d = 3, arr = '{'h2, 'h3, 'h3, 'h7, 'h9, 'h6, 'h5, 'ha, 'h1, 'h4} sum = 50
d = 9, arr = '{'h7, 'h8, 'h9, 'h9, 'h3, 'h1, 'h2, 'h4, 'ha, 'h6} sum = 59

What I don’t understand is that, we are not constraining the values of ‘d’, still the value of ‘d’ seems to co-relate with the array elements. Which part of the constraint takes care of that? Can you please elaborate.