Function to return the sum of values stored from O to idx index in the array using Fenwick Tree
static int query ( int idx , int [ ] bit ) { int res = 0 ; while ( idx > 0 ) { res += bit [ idx ] ; idx -= idx & ( - idx ) ; } return res ; }