Constrain sum of elements in an array

In reply to muneebullashariff:

Can you think of a solution that should have worked?