#include #define show(x) cout << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; template T gcd(const T a, const T b) { return b ? gcd(b, a % b) : a; } template T lcm(const T a, const T b) { return (a / gcd(a, b)) * b; } int main() { int N; cin >> N; ll L, H; cin >> L >> H; vector c(N); ll total = 0; for (ll i = 0; i < N; i++) { cin >> c[i]; total += H / c[i] - (L - 1) / c[i]; } const int maximum = 1 << N; for (int i = 1; i < maximum; i++) { int num = i; int cnt = 0; ll d = 1; for (int j = 0; j < N; j++) { if (num % 2 == 1) { cnt++; d = lcm(d, c[j]); } num /= 2; } if (cnt <= 1) { continue; } if (cnt % 2 == 0) { total -= cnt * ((H / d) - (L - 1) / d); } else { total += cnt * ((H / d) - (L - 1) / d); } } cout << total << endl; return 0; }