import math from sys import stdin n, m, *a = map(int, stdin.read().split()) p = 10**9+7 divideset = set() for i in range(1,int(math.floor(math.sqrt(m)))+2): if m % i == 0: divideset.add(i) divideset.add(m//i) dividelist = list(divideset) dividelist.sort() dividedict = dict() nd = len(dividelist) for i in range(nd): dividedict[dividelist[i]] = i check = True for i in range(n): kari = math.gcd(a[i],m) a[i] = kari if kari != m: check = False if check: ans = 1 for i in range(n): ans = ans * 2 % p ans = (ans - 1) % p print("{}".format(ans)) exit() dp = [[0 for i in range(nd)] for j in range(n+1)] dp[0][0] = 1 for i in range(n): for j in range(nd): kari = a[i] * dividelist[j] val = math.gcd(kari,m) dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % p dp[i+1][dividedict[val]] = (dp[i+1][dividedict[val]] + dp[i][j]) % p ans = dp[n][nd-1] print("{}".format(ans))