#ABC474F. 将所有约数加一 / Increment All Divisors

将所有约数加一 / Increment All Divisors

Problem Statement

You are given a length-NN integer sequence A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N). You can perform the following operation on AA any number of times.

  • Choose an integer ii with 1iN1 \leq i \leq N. For every integer jj that is a positive divisor of ii, add 11 to AjA_j.

Determine whether it is possible to make all elements of AA equal, and if it is possible, find the minimum number of operations required to do so.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 1Ai1091 \leq A_i \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN
  • A1A_1 A2A_2 \dots ANA_N

Output

If it is possible to make all elements of AA equal, output, in one line, the minimum number of operations required to do so; otherwise, output 1-1.

3
4 7 4
3

If you choose i=3i=3 for the first operation, you get A=(5,7,5)A=(5,7,5). If you choose i=3i=3 for the second operation, you get A=(6,7,6)A=(6,7,6). If you choose i=3i=3 for the third operation, you get A=(7,7,7)A=(7,7,7). It is impossible to make all elements of AA equal with fewer than three operations, so the answer is 33.

5
1 3 4 5 6
5
2
5 2
-1