#include #define rep(i, n) for (lli i = 0; i < (n); i++) #define rrep(i, n) for (lli i = (n)-1; i >= 0; i--) using namespace std; using lli = long long int; lli lcm(lli l, lli r) { return l / __gcd(l, r) * r; } lli memo_h[1 << 20], memo_l[1 << 20]; int main() { lli c[20], l, h; int n; cin >> n >> l >> h; lli sum_l = 0, sum_h = 0; rep(i, n) cin >> c[i]; for (int i = 0; i < (1 << n); i++) { lli LCM = 1; rep(j, n) { if ((i >> j) & 1) { LCM = lcm(LCM, c[j]); } } lli count = __builtin_popcount(i); sum_h += (count & 1 ? 1 : -1) * count * (h / LCM); sum_l += (count & 1 ? 1 : -1) * count * ((l - 1) / LCM); //memo_h[i] = h / LCM; //memo_l[i] = (l - 1) / LCM; } cout << sum_h - sum_l << endl; }