Running loop from p times which is the number of bits required to represent all the elements of the array
let X = 0 ; for ( let i = 0 ; i < p ; i ++ ) { let count = 0 ; for ( let j = 0 ; j < n ; j ++ ) {