from sys import exit from math import gcd mod = 10**9+7 def factors(a): if a <= 0: return [0] dd0, dd1 = [], [] for d in range(1, round(a**0.5)+1): if a%d: continue dd0.append(d) dd1.append(a//d) if dd0[-1] == dd1[-1]: dd1.pop() return dd0+dd1[::-1] n,k=map(int,input().split()) A=list(map(lambda x:gcd(int(x),k),input().split())) if k == 1: print(pow(2,n,mod)-1) exit() factor = factors(k) ftoj = {f: j for j, f in enumerate(factor)} fn = len(factor) dp = [0]*fn dp[0] = 1 cnt=0 B=[] for x in A: if x==1: cnt+=1 else: B.append(x) for b in B: for j in range(fn)[::-1]: pre = dp[j] if pre == 0: continue g = gcd(b*factor[j], k) nj = ftoj[g] dp[nj] += pre dp[nj] %= mod print(dp[-1])