The cows have hatched a daring plan to escape from Farmer John's clutches. They have gotten hold of a small inflatable raft, and under cover of night a group of cows will board the raft and row across the river that borders the farm. The plan seems perfect — until the cows realize that their tiny raft may not be able to hold much weight!
The $N$ cows ($1 \le N \le 20$) have weights $w_1, \dots, w_N$. To decide whether a group of cows is light enough not to sink the raft, the cows add up all of the weights in the group. Unfortunately the cows are notoriously bad at arithmetic: if adding the weights of the cows in a group produces any carry (using standard base-10 addition), the cows give up and conclude that the group must be too heavy for the raft. Any group whose weights can be added with no carries is assumed to be light enough to fit on the raft.
Help the cows determine the size of the largest group they believe can fit on the raft — that is, the largest group whose weights can be added together with no carries.
There are 5 cows, with weights 522, 6, 84, 7311, and 19.
The three weights 522, 6, and 7311 can be added together with no carries:
522
6
+ 7311
------
7839