#include #include #include long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } long long lcm(long long x, long long y) { return std::min(1000000001LL, x / gcd(x, y) * y); } long long f(long long x, std::vector c) { const int n = c.size(); // |A * !B * !C| + |!A * !B * !C| = |!B * !C| // |A * !B * !C| = |!B * !C| - |!A * !B * !C| std::vector cnt(1 << n); for (int i = 0; i < 1 << n; i++) { long long l = 1; for (int j = 0; j < n; j++) { if (i >> j & 1) { l = lcm(l, c[j]); } } cnt[i] = x / l; } for (int i = 0; i < n; i++) { for (int j = 0; j < 1 << n; j++) { if (~j >> i & 1) { cnt[j | 1 << i] -= cnt[j]; } } } // |A| |B| |A*B| // cnt[00] = x // cnt[01] = |A|-x // cnt[10] = |B|-x // cnt[11] = |A*B|-|A|+x-|B| for (int i = 0; i < 1 << n; i++) { int p = 1; for (int j = 0; j < n; j++) { if (i >> j & 1) { p *= -1; } } cnt[i] *= p; } long long ret = 0; for (int i = 0; i < n; i++) { int u = ((1 << n) - 1) ^ (1 << i); int v = ((1 << n) - 1); ret += cnt[u] - cnt[v]; } return ret; } int main() { long long N, L, H; std::cin >> N >> L >> H; std::vector c(N); for (int i = 0; i < N; i++) { std::cin >> c[i]; } std::cout << f(H, c) - f(L - 1, c) << std::endl; }