N, L, H = gets.split.map &:to_i C = gets.split.map &:to_i def solve x, c res = 0 1.upto((1 << c.size) - 1) do |s| lcm, cnt = 1, 0 c.size.times do |i| next if (s >> i & 1) == 0 cnt += 1 lcm = lcm * c[i] / lcm.gcd(c[i]) end if (cnt & 1) == 1 res += x / lcm * cnt else res -= x / lcm * cnt end end res end p solve(H, C) - solve(L - 1, C)