Count of elements arriving at a given point at the same time
int count = 1 ; while ( ( j < ( T . Count - 1 ) ) && ( Convert . ToDouble ( T [ j ] ) . CompareTo ( Convert . ToDouble ( T [ j + 1 ] ) ) == 0 ) ) { count += 1 ; j += 1 ; } total += ( count * ( count - 1 ) ) / 2 ; j += 1 ; } return total ; }