#include #pragma GCC target("arch=skylake") #pragma GCC optimize("Ofast") #define endl '\n' using namespace std; using ll=long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n; vector x(n); for(int i=0;i>x[i]; vector sum(n); for(int i=0;i>q; while(q--){ ll l,r,s; cin>>l>>r>>s; --l; --r; if(sum[r]-sum[l]>60||(1ll<<(sum[r]-sum[l]))>s){ cout<<0<=90){ cout<<1<1){ int m=(ok+ng)/2; vector mp(n+1); int cnt=0; vector dp(r-l+3); bool isok=false; dp[0]=1; dp[1]=-1; for(int i=0,j=0;im){ cnt--; break; } mp[x[j+l]]++; j++; } if(dp[i]>s){ isok=true; break; } dp[i+1]+=dp[i]*2; dp[j+1]-=dp[i]; mp[x[i+l]]--; if(mp[x[i+l]]==0) cnt--; } if(isok||dp[r-l+1]>s) ng=m; else ok=m; } cout<