Function to obtain and return the index of lower_bound of k
function getLowerBound ( BITree , arr , n , k ) { let lb = - 1 ; let l = 0 , r = n - 1 ; while ( l <= r ) { let mid = Math . floor ( l + ( r - l ) / 2 ) ; if ( getSum ( BITree , mid ) >= k ) { r = mid - 1 ; lb = mid ; } else l = mid + 1 ; } return lb ; } function performQueries ( A , n , q ) {