#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N, L, H; cin >> N >> L >> H; vector C(N); vector> primes(N); for(int i = 0; i < N; ++i){ cin >> C[i]; int X = C[i]; for(int j = 2; j * j <= X; ++j){ while(X % j == 0){ primes[i][j] += 1; X /= j; } } if(X != 1) primes[i][X] = 1; } if(N == 1){ cout << H / C[0] - (L + C[0] - 1) / C[0] + 1 << '\n'; return 0; } ll ans = 0; for(int i = 0; i < N; ++i){ auto A = C; vector idx; auto primes2 = primes; for(int j = 0; j < N; ++j){ if(j != i){ int g = gcd(A[i], A[j]); A[j] /= g; idx.emplace_back(j); for(auto& [p, cnt] : primes2[j]){ while(g % p == 0 && cnt > 0){ g /= p; --cnt; } } } } int lower = (L + A[i] - 1) / A[i], upper = H / A[i]; ll sum = 0; for(int mask = 0; mask < 1 << (N - 1); ++mask){ map lcm_prime; for(int j = 0; j < N - 1; ++j){ if(mask >> j & 1){ for(auto& [p, cnt] : primes2[idx[j]]){ chmax(lcm_prime[p], cnt); } } ll LCM = 1; for(auto& [p, cnt] : lcm_prime){ for(int i = 0; i < cnt; ++i){ if((LCM *= p) > upper) break; } if(LCM > upper) break; } if(LCM > upper) continue; if(__builtin_popcount(mask) % 2 == 0){ sum += upper / LCM - (lower + LCM - 1) / LCM + 1; } else{ sum -= upper / LCM - (lower + LCM - 1) / LCM + 1; } } } ans += sum; } cout << ans << endl; return 0; }