Increasing Decreasing Digits

Increasing Decreasing Digits
hard

A number is called beautiful if it has at least \(3\) digits, does not contain the digit \(0\), and its digits form a strictly increasing sequence (of length at least \(2\)) from the beginning up to some digit, and then a strictly decreasing sequence (of length at least \(2\)) from that digit to the end.

For example, the numbers \(125862\), \(565\), and \(89731\) are beautiful, while \(23241\), \(89722\), and \(1234\) are not.

For a given natural number \(A\), determine the smallest beautiful number that is strictly greater than \(A\).

For example, for \(A = 320557\), the output should be \(35321\).

You can assume that \(100 \leq A \leq 10^7\).

If this seems too hard, you can try first to solve this task assuming that both \(A\) and the solutions will have \(3\) digits.