public SegmentTreeMinCntSegAdd(int[] array){
            int n = array.length, i;
            for(d=1; d<n; d<<=1);
            t = new int[d<<1];
            add = new int[d<<1];
            cntMin = new int[d<<1];
            for(i=d; i<n+d; ++i){ t[i] = array[i-d]; cntMin[i] = 1; }
            for(i=n+d; i<d+d; ++i){ t[i] = Integer.MAX_VALUE; cntMin[i] = 1; }
            for(i=d-1; i>0; --i){
                if(t[i*2]<t[i*2+1]){
                    t[i] = t[i*2];
                    cntMin[i] = cntMin[i*2] + (t[i*2]==t[i*2+1] ? cntMin[i*2+1] : 0);
                }else{
                    t[i] = t[i*2+1];
                    cntMin[i] = cntMin[i*2+1] + (t[i*2]==t[i*2+1] ? cntMin[i*2] : 0);
                }
            }
        }