Candy's Candy

No attempts yetTime limit1sMemory limit128 MB

Problem

Candy has candy in $F$ different flavors, and she wants to make several packs to sell them. Each pack is one of two kinds:

  • flavored pack: contains candy of a single flavor;
  • variety pack: contains candy of every flavor.

Candy calls a packing nice if it satisfies all of the following conditions:

  • Every piece of candy is placed in exactly one pack.
  • Every pack, of either kind, contains at least $2$ pieces of candy.
  • Every pack, of either kind, contains the same number of pieces of candy.
  • Within each variety pack, the number of pieces of each flavor is the same.
  • There is at least one variety pack.
  • For every flavor, there is at least one flavored pack of that flavor.

Candy wonders how many different nice packings she can make. Two nice packings are considered different if they differ in the number of flavored packs, in the number of variety packs, or in the number of pieces of candy per pack.

Input

The input consists of several test cases. Each test case is given on two lines. The first line contains an integer $F$ ($2 \le F \le 10^5$), the number of flavors. The second line contains $F$ integers $C_i$ ($1 \le C_i \le 10^9$), the number of pieces of candy of each flavor.

The last test case is followed by a line containing a single $0$.

Output

For each test case, output on its own line the number of different nice packings that can be made according to the rules above.