This page is still under construction.

Parts of this page are still being built. What you see may change.

Arrays and gcd

Time limit0.5sMemory limit128 MB

Summary
Count arrays arr with elements in [1, num] whose running gcd array equals the given array C, modulo 1e9+7.
Level

Medium7 of 10

Topics
Number theory, Dynamic programming, Math, Combinatorics
Solved
No attempts yet

Problem

There are two integer arrays of size NN, called arrarr and CC. They satisfy the following relation.

C[0]=arr[0],C[i]=gcd⁡(C[i−1], arr[i])(1≤i≤N−1)C[0] = arr[0], \qquad C[i] = \gcd(C[i-1],\, arr[i]) \quad (1 \le i \le N-1)

Here gcd⁡(x,y)\gcd(x, y) is the greatest common divisor of xx and yy.

For example, arr=[16,16,8,16,2]arr = [16, 16, 8, 16, 2] gives C=[16,16,8,8,2]C = [16, 16, 8, 8, 2].

Given the array CC, find the number of arrays arrarr that produce it, modulo 10000000071000000007 (109+710^9+7). Every element of arrarr is an integer between 11 and numnum.

Input

The first line contains two integers NN (1≤N≤1051 \le N \le 10^5) and numnum (1≤num≤1091 \le num \le 10^9), separated by a space.

The second line contains the elements of the array CC, that is C[0],C[1],…,C[N−1]C[0], C[1], \ldots, C[N-1], separated by spaces. (1≤C[i]≤num1 \le C[i] \le num)

Output

Print the number of arrays arrarr that satisfy the conditions, modulo 109+710^9+7, on the first line.

Examples4

  1. Example 1

    Input
    3 900
    900 450 225
    
    Expected output
    2
    
  2. Example 2

    Input
    5 16
    16 16 8 8 2
    
    Expected output
    8
    
  3. Example 3

    Input
    4 10
    6 4 2 2
    
    Expected output
    0
    
  4. Example 4

    Input
    1 1000000000
    7
    
    Expected output
    1