//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 100010001; const ll LINF = (ll)INF*INF*10; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;} int64_t lcm(int64_t a, int64_t b) {return (ll)min((ld)a/gcd(a,b)*b, (ld)1e17);} int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える int64_t d = a; if(b) { d = extgcd(b, a%b, y, x); y -= (a/b)*x; } else { x = 1; y = 0; } return d; } int func(int d, vi &c) { if(!d) return 0; int n = c.size(); vi dp(1<>j&1) { x = lcm(x, c[j]); } dp[i] = d/x; } rep(i, n) rep(j, 1<>i&1) dp[j^(1<> n >> l >> h; vi c(n); rep(i, n) cin >> c[i]; cout << func(h, c)-func(l-1, c) << endl; }