Daisies and Love

No attempts yetTime limit1sMemory limit1024 MB

Problem

An M-state affection list (with $M > 1$) is a sequence defined as follows: the first entry is the state “loves”, and the remaining $M-1$ entries are some other (distinct) affection states.

A girl reads a boy's feelings toward her by plucking, one at a time, the petals of a daisy he gives her, using the following rules:

  1. Before the first petal is plucked, we are in the state “loves”.
  2. Each time a petal is plucked, the affection state advances to the next state in the list.
  3. The state that follows the last state in the list is again “loves” (the list wraps around).
  4. When the flower has no petals left, we finish with this daisy and return the current state as its result.

For example, consider the $3$-state list “loves”-“likes”-“indifferent”. With this list, a daisy of $5$ petals gives the result “indifferent”, while a daisy of $7$ petals gives “likes”.

The girl believes the boy loves her only if he gives her daisies and every one of them points to the state “loves”. The boy wants to convince her, so he gives her $N$ daisies and wants to design the longest possible affection list.

For the given daisies, find the largest value of $M$ for which the girl concludes that the boy loves her.

Input

The first line contains the number of daisies $N$ ($1 \le N \le 1000$). The second line contains $N$ integers $L_i$ ($1 \le L_i \le 100$) separated by spaces, where $L_i$ is the number of petals on the $i$-th daisy.

Output

Print a single integer: the largest possible value of $M$. If the petal counts of the daisies share no common divisor greater than $1$, print $1$.