Divisible LCM

You have a sequence a1, a2, a3, …, ana_1,~ a_2,~ a_3,~…, ~a_na1​, a2​, a3​, …, an​ of n integers and qqq queries. In each query, you are given three integers lll, rrr and xxx. You have to answer the following question:


This is a companion discussion topic for the original entry at https://toph.co/p/just-lcm