Under construction

Still being built. Things may change

Transformed Sequence

Time limit1sMemory limit512 MB

Summary
Given each D_i, find the lexicographically smallest permutation T on a cycle of N points with circular distance D(i, T_i) for every i, or report No Answer.
Level

Medium7 of 10

Topics
Greedy, Graph
Solved
No attempts yet

Problem

For NN integers 0,1,…,N−10, 1, \ldots, N-1, a transformed sequence TT changes each ii to TiT_i, where Ti∈{0,1,…,N−1}T_i \in \{0, 1, \ldots, N-1\} and ⋃i=0N−1{Ti}={0,1,…,N−1}\bigcup_{i=0}^{N-1} \{T_i\} = \{0, 1, \ldots, N-1\}. For all x,y∈{0,1,…,N−1}x, y \in \{0, 1, \ldots, N-1\}, the distance between xx and yy is D(x,y)=min⁡{∣x−y∣,N−∣x−y∣}D(x, y) = \min\{|x - y|, N - |x - y|\}. Given the distance D(i,Ti)D(i, T_i) for each ii, find a transformed sequence TT that satisfies these requirements. If several sequences satisfy them, output the lexicographically smallest one.

Note: For two transformed sequences SS and TT, SS is lexicographically smaller than TT if there exists a p<Np < N such that Si=TiS_i = T_i for i=0,1,…,p−1i = 0, 1, \ldots, p-1 and Sp<TpS_p < T_p.

Input

The first line contains a single integer NN, the length of the sequence. The next line contains NN integers DiD_i, where DiD_i is the distance between ii and TiT_i.

Output

If at least one transformed sequence TT exists, print one line with NN integers, the lexicographically smallest TT. Otherwise, print No Answer. Separate adjacent numbers with a single space, and do not leave a trailing space.

Constraints

N≤10000N \le 10000

Examples1

  1. Example 1

    Input
    5
    1 1 2 2 1
    
    Expected output
    1 2 4 0 3