import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.container; // SList, DList, BinaryHeap import std.typecons; // Tuple, Nullable, BigFlags import std.math; // math functions import std.numeric; // gcd, fft import std.bigint; // BigInt import std.random; // random import std.bitmanip; // BitArray import core.bitop; // bit operation import std.regex; // RegEx import std.uni; // unicode void main() { auto rd = readln.split.to!(BigInt[]), n = rd[0].to!int, l = rd[1], h = rd[2]; auto c = readln.split.to!(BigInt[]); writeln(f(n, c, h) - f(n, c, l-1)); } auto f(int n, BigInt[] c, BigInt m) { auto r = BigInt(0); foreach (i; 1..1 << n) { auto d = c.indexed(i.bitsSet).array; auto t = (-1) ^^ (i.popcnt - 1) * i.popcnt * calc(m, d); r += t; } return r; } auto calc(BigInt n, BigInt[] c) { auto l = c.fold!((a, b) => lcd(a, b)); auto r = n / l; return r; } BigInt lcd(BigInt a, BigInt b) { return a / gcd(a, b) * b; } BigInt gcd(BigInt a, BigInt b) { if (a < b) return gcd(b, a); if (a % b == 0) return b; return gcd(b, a % b); } pragma(inline) { pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; } pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); } pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); } pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); } pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); } pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); } pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); } import core.bitop; pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); } pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); } pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); } }