Counting the numbers whose flag are true .
cnt = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( f [ i ] ) { cnt ++ ; } } long NumberOfTriplets = ( cnt * ( cnt - 1 ) * ( cnt - 2 ) ) / 6 ; Console . Write ( NumberOfTriplets + " ▁ " + ans ) ; }