## NPERM - Next Permuation

Given a permutation P of the integers between 1 and n, find the smallest permutation Q sctrictly greater than P.

Permutations are compared lexicographically.

### Input

In the first line there is an integer 1≤n≤10^{5}, the size of the permutation P.

In the next line, n different integers, 1 ≤ a_{i }≤ n, representing the permutation P.

### Output

Single line with n integers, containing the permutation Q, or "NO" if the permutation does not exist.

### Example

Input:2

1 2Output:2 13

Input:

3 2 1

Output:

NO

Added by: | Marcelo Fornet |

Date: | 2018-01-09 |

Time limit: | 1s |

Source limit: | 50000B |

Memory limit: | 1536MB |

Cluster: | Cube (Intel G860) |

Languages: | All |