#include using namespace std; #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define spa << " " << #define test cout<<"test"<; void chmin(ll &a,ll b){if(a>b)a=b;} void chmax(ll &a,ll b){if(a>v,ll h,ll w){for(ll i=0;iv,ll h,ll w){for(ll i=0;iv,ll n){cout<second++; map factoring(ll n){ ll buf=n; mapret; ll i,j; for(i=2;buf!=1&&i*i<=n;i++){ for(j=0;buf%i==0;j++){ buf/=i; } if(i>0)ret.emplace(i,j); } if(buf!=1)ret.emplace(buf,1); return ret; } int main(){ ll res=0,res1=INF,res2=-INF,buf=0; bool judge = true; ll n;cin>>n; vectora(n); rep(i,0,n)cin>>a[i]; ll q;cin>>q; vectorp(q),l(q),r(q); rep(i,0,q)cin>>p[i]>>l[i]>>r[i]; vector>v(n+1); rep(i,2,2001){ judge=true; rep(j,2,i-1)if(i%j==0)judge=false; if(judge)v[0].emplace(i,0); } rep(i,0,n){ auto m=factoring(a[i]); for(auto z:v[i]){ if(m.find(z.fi)!=m.end()){ v[i+1].emplace(z.fi,z.se+m[z.fi]); } else v[i+1].emplace(z.fi,z.se); } } rep(i,0,q){ auto m=factoring(p[i]); judge=true; for(auto z:m){ //cout<