#include #include #include #include #define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++) using namespace std; typedef long long ll; int N; ll L, H, C[10]; template void parted_rotate(FI first1, FI last1, FI first2, FI last2) { if(first1 == last1 || first2 == last2) return; FI next = first2; while(first1 != next) { std::iter_swap(first1++, next++); if(first1 == last1) first1 = first2; if(next == last2) { next = first2; } else if(first1 == first2) { first2 = next; } } } template bool next_combination_imp(BI first1, BI last1, BI first2, BI last2) { if(first1 == last1 || first2 == last2) return false; auto target = last1; --target; auto last_elem = last2; --last_elem; while(target != first1 && !(*target < *last_elem)) --target; if(target == first1 && !(*target < *last_elem)) { parted_rotate(first1, last1, first2, last2); return false; } auto next = first2; while(!(*target < *next)) ++next; std::iter_swap(target++, next++); parted_rotate(target, last1, next, last2); return true; } template inline bool next_combination(BI first, BI mid, BI last) { return next_combination_imp(first, mid, mid, last); } ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main(void) { cin >> N >> L >> H; REP(i, 0, N) cin >> C[i]; ll fact[11]; fact[0] = 1; REP(i, 0, 10) fact[i + 1] = fact[i] * (i + 1); ll ans = 0; REP(i, 1, N + 1) { ll a[20]; REP(i, 0, N) a[i] = i; ll cnt = 0; do { ll p = 1; REP(j, 0, i) p = lcm(p, C[a[j]]); cnt += H / p - (L - 1) / p; } while(next_combination(a, a + i, a + N)); ans += (i % 2 == 0 ? -1 : 1) * i * cnt; } cout << ans << endl; }