Function to return the query result
int query ( int * Fenwick , int index , int n ) { int sum = 0 ; while ( index > 0 ) { sum = sum + Fenwick [ index ] ; index -= index & ( - index ) ; } return sum ; }