Function to return the query result
def query ( Fenwick : List [ int ] , index : int , n : int ) -> int : NEW_LINE INDENT summ = 0 NEW_LINE while ( index > 0 ) : NEW_LINE INDENT summ = summ + Fenwick [ index ] NEW_LINE index -= index & ( - index ) NEW_LINE DEDENT return summ NEW_LINE DEDENT