Function to update the value in Fenwick tree
def update ( Fenwick : List [ int ] , index : int , val : int , n : int ) -> None : NEW_LINE INDENT while ( index <= n ) : NEW_LINE INDENT Fenwick [ index ] += val NEW_LINE index += index & ( - index ) NEW_LINE DEDENT DEDENT