#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x ostream& operator<<(ostream& os, const pair& p){ return os << "{" << p.first << ", " << p.second << "}"; } template ostream& operator<<(ostream& os, const vector& obj) { os << "{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } template ostream& operator<<(ostream& os, const set& obj) { os << "set{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } template ostream& operator<<(ostream& os, const map& obj) { os << "map{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } #ifdef ONLINE_JUDGE #define dump(expr) ; #else #define dump(expr) { cerr << "\033[33m#L" << __LINE__ << ": " << expr << "\033[39m" << endl; } #endif ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll solve() { ll n, low, high; cin >> n >> low >> high; vector vs(n); for (int i : range(n)) cin >> vs[i]; ll res = 0; for (int i : range(n)) { int a = vs[i]; vector bs; for (int j : range(n)) if (j != i) bs.push_back(vs[j] / gcd(a, vs[j])); dump(bs); ll tot = 0; for (int bit : range(1 << (n - 1))) { ll b = 1; for (int j : range(n - 1)) if ((bit >> j) & 1) { b = lcm(b, bs[j]); if (b * a > high) break; } b *= a; ll count = high / b - (low - 1) / b; ll sign = (__builtin_popcount(bit) % 2) ? -1 : 1; dump(i << " " << bit << " " << count * sign << " b=" << b) tot += count * sign; } dump(i << " => " << tot); res += tot; } return res; } int main() { cout << fixed << setprecision(12); cout << solve() << endl; }