Iterate over the ranges
for ( int i = 0 ; i < r ; i ++ ) { int c = 0 ; int l = ranges [ i , 0 ] ; int h = ranges [ i , 1 ] ; for ( int j = 0 ; j < arr . Length ; j ++ ) { if ( l <= arr [ j ] && arr [ j ] <= h ) c += 1 ; } a . Add ( c ) ; } foreach ( var i in a ) { Console . Write ( i + " ▁ " ) ; } }