Is there an alternative to sum() Constraint

In reply to Have_A_Doubt:

$countones, $onehot, and $isunknown are just shortcuts for $countbits usage.

You could use a foreach loop with a helper unpacked array that is a cascading sum of the previous iteration. I’ll leave that as an exercise for you.