Initialize the low and high of array
INDENT low = v [ n - 1 ] NEW_LINE high = v [ n - 1 ] NEW_LINE p1 = n NEW_LINE p2 = n ; NEW_LINE ans = 0 ; NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT x = v [ i ] ; NEW_LINE DEDENT DEDENT