I can compute the answer, but I am using recursion and it breaks my computer quite fast. 8 elements takes 30 seconds and 9 elements ... well, I gave up waiting after 5 minutes.
Some research for a better algorihtm led me to complexity theory and specifically a set of problems known as NP-complete or Non-deterministic Polynomial time.
From our friends at Wikipedia:
In computational complexity theory, NP ("Non-deterministic Polynomial time") is the set of decision problems solvable in polynomial time on a non-deterministic Turing machine. Equivalently, it is the set of problems whose solutions can be "verified" by a deterministic Turing machine in polynomial time.
My knowledge finds it's limit at Wikipedia ... going through some of the theories to try and find some sort apporimation alogirthm is doing my head in. If any of the mathematically inclined what to take a stab at it I will buy you many beers.
Did you know there is such a thing as recreational mathematics?
Madness.
Update: now I am looking at Diophantine linear equations. Don't ask.