Count of elements arriving at a given point at the same time
int count = 1 ; while ( i < T . size ( ) - 1 and T [ i ] == T [ i + 1 ] ) { count += 1 ; i += 1 ; } total += ( count * ( count - 1 ) ) / 2 ; i += 1 ; } return total ; }