#P3598. Koishi Loves Number Theory

Koishi Loves Number Theory

Description

Koishi loves number theory.

Her friend Flandre, to check whether her love for number theory is true, gave her a problem.

Given f(n)=i=0nxif(n)=\sum_{i=0}^n x^i.

Given xx and NN numbers aia_i, compute lcm(f(a1),f(a2),...,f(aN))\mathrm{lcm}(f(a_1),f(a_2),...,f(a_N)) modulo 109+710^9+7.

As usual, the naive Koishi pretended she could not solve it and came to ask you, hoping you can give the answer within 1 second.

Input Format

The first line contains two integers xx and NN. The next line contains NN integers representing aia_i.

Output Format

One integer, the answer.

3 5
1 2 4 5 0
44044

Hint

lcm\mathrm{lcm} denotes the least common multiple of several numbers.

Constraints:

  • For 10%10\% of the testdata, 1N1001 \leq N \leq 100, 0ai90 \leq a_i \leq 9, x=2x=2.
  • For another 20%20\% of the testdata, 1N501 \leq N \leq 50, 0ai1000 \leq a_i \leq 100, 2x102 \leq x \leq 10.
  • For another 30%30\% of the testdata, 1N161 \leq N \leq 16, 0ai1090 \leq a_i \leq 10^9, 2x10182 \leq x \leq 10^{18}.
  • For 100%100\% of the testdata, 1N1001 \leq N \leq 100, 0ai1090 \leq a_i \leq 10^9, 2x10182 \leq x \leq 10^{18}, and x≢1(mod109+7)x \not\equiv 1 \pmod{10^9+7}.

Translated by ChatGPT 5