Escaping the Farm

No attempts yetTime limit1sMemory limit128 MB

Problem

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.

Input

  • Line 1: the number of cows, $N$ ($1 \le N \le 20$).
  • Lines 2 to $N+1$: each line contains the weight of one cow, an integer between 1 and 100,000,000 inclusive.

Output

  • Line 1: the number of cows in the largest group whose weights can be added together with no carries.

Hint

Input Details

There are 5 cows, with weights 522, 6, 84, 7311, and 19.

Output Details

The three weights 522, 6, and 7311 can be added together with no carries:

   522
     6
+ 7311
------
  7839