Binary search to find minimum ans
while ( lo < hi ) : NEW_LINE INDENT mid = ( lo + hi ) // 2 NEW_LINE if ( check ( a , n , mid ) ) : NEW_LINE INDENT ans = mid NEW_LINE hi = mid NEW_LINE DEDENT else : NEW_LINE INDENT lo = mid + 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE