Under construction

Still being built. Things may change

Equal remainders

Time limit1sMemory limit1024 MB

Summary
Given N distinct integers A and a value K, find the smallest positive M so that s^K lies in S(A^M) for every s in S(A), modulo 1e9+7, or -1.
Level

Hard8 of 10

Topics
Number theory, Math
Solved
No attempts yet

Problem

The definition of remainders and divisibility is extended from positive integers to all integers as follows.

  • For an integer aa and a positive integer qq, the remainder rr of aa divided by qq is the value with 0≤r<q0\le r<q for which a=qx+ra=qx+r holds for some integer xx. This is written a≡r(modq)a\equiv r\pmod q.
  • An integer aa is divisible by a positive integer qq when the remainder of aa divided by qq is 00.

Given a set of integers AA and a positive integer MM, define AMA^M as follows.

  • S(A):={q∈Z+∣∃r≠0:∀x∈A, x≡r(modq)∧gcd⁡(q,x)=1}S(A) := \{ q \in \mathbb{Z}^{+} \mid \exists r \ne 0 : \forall x \in A,\ x \equiv r \pmod q \land \gcd(q, x) = 1 \}
  • AM:={sgn⁡(x)⋅∣x∣M∣x∈A}A^M := \{ \operatorname{sgn}(x) \cdot |x|^M \mid x \in A \}

Here sgn⁡(x):=x/∣x∣\operatorname{sgn}(x) := x/|x| for x≠0x\ne 0 and sgn⁡(0)=0\operatorname{sgn}(0) = 0.

In plain terms, S(A)S(A) is the set of positive integers qq such that every element of AA leaves the same nonzero remainder when divided by qq, and every element of AA is coprime to qq. AMA^M is the set of numbers that have the same sign as each element of AA and whose absolute value is that element's absolute value raised to the power MM.

Given a set AA of NN distinct integers and a nonnegative integer KK, find the smallest positive integer MM such that

  • ∀s∈S(A), sK∈S(AM)\forall s\in S(A),\ s^K\in S(A^M)

Input

The first line contains positive integers NN (2≤N≤1052\le N\le 10^5) and KK (1≤K≤10171\le K\le 10^{17}), separated by a space.

The second line contains NN distinct integers AiA_i (−1018≤Ai≤1018-10^{18}\le A_i\le 10^{18}) in ascending order, separated by spaces.

Output

Print the smallest positive integer MM that satisfies the condition, modulo 109+710^9+7, since the answer can be very large.

If no such MM exists, print -1 instead.

Examples5

  1. Example 1

    Input
    2 4
    3 5
    
    Expected output
    2
    
  2. Example 2

    Input
    2 5
    3 5
    
    Expected output
    4
    
  3. Example 3

    Input
    2 1
    -1 1
    
    Expected output
    1
    
  4. Example 4

    Input
    2 2
    -1 1
    
    Expected output
    -1
    
  5. Example 5

    Input
    3 100000000000000000
    -1000000000000000000 -371681469282041354 570796326794896615
    
    Expected output
    487180136