Function to precompute prefix sum of numerical strings
def precomputePrefix ( st , n ) : NEW_LINE INDENT pref [ 0 ] = ( ord ( st [ 0 ] ) - ord ( '0' ) ) NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT pref [ i ] = ( pref [ i - 1 ] + toDigit ( st [ i ] ) ) NEW_LINE DEDENT DEDENT