#include #include #include #include typedef long long ll; using namespace std; bool mark[200009]; int main(){ int a,b,c,d,e,f,g,h; scanf("%d",&b); while(b--){ ll re=0; scanf("%d%d%d",&a,&e,&f); for(d=1;d<=a;d++){ scanf("%d",&g); if(g>=e){ mark[d]=1; } else mark[d]=0; } ll l=-1,r,pre=0; for(d=1,c=0;d<=a;d++){ if(mark[d]){ c++; if(l==-1)l=d; } if(c==f){ r=d; re+=((ll)a-r+1ll)*(l-pre); //printf("%lld %lld %lld\n",pre,l,r); pre=l; l++; while(!mark[l])l++; c--; } //printf(" %lld %lld %lld\n",re,pre,l); } cout<