How to constraint the sum of array elements

Use

constraint c_sum {array.sum() < 2345;}

You may want to use int unsigned if you do not want to consider negative numbers in the array.