#include #include #include using namespace std; const int N = 10; typedef long long int ll; ll dp[1 << N] = {}, n, l, h, val[N] = {}; int nmb(long bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } ll gcd(ll a, ll b) { if (a == 0)return b; if (b == 0)return a; ll a2 = max(a, b), b2 = min(a, b); return gcd(b2, a2%b2); } ll lcm(ll a, ll b) { return a / gcd(a, b)*b; } ll ans = 0; int main() { cin >> n >> l >> h; for (int i = 0; i < n; i++) cin >> val[i]; for (int s = 0; s < (1 << n); s++) { ll cd = 1; for (int i = 0; i < n; i++) { if ((s >> i) & 1)cd = lcm(cd, val[i]); if (cd > h)break; } dp[s] = h / cd - (l - 1) / cd; } for (int s = 0; s < (1 << n); s++) { int cnmb = nmb(s); if (cnmb % 2 == 0)ans -= cnmb * dp[s]; else ans += cnmb * dp[s]; } cout << ans << endl; return 0; }