Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 32768/32768 K (Java/Others)

There are N IT companies which are labeled from 1 to N. Each of them has a branch (a branch is not a company, and companies and branches are all called "unit").The branches are labeled from -1 to –N. The branch of company i is labeled as -i. The number of workers of each company and its branch has to fit the rules below:

1. The number of workers of a company must be larger than that of the branch of it.

2. There are more workers in company i than company j if and only if there are more workers in the branch of company i than the branch of company j.

Among the companies whose label is larger than i（range from i+1 to n）,and the branches whose label is larger than -i (range from -1 to –(i-1) ), there are c[i] units which have more workers than company i.

You need to sort the 2×N units in the ascending order by the number of workers.

1. The number of workers of a company must be larger than that of the branch of it.

2. There are more workers in company i than company j if and only if there are more workers in the branch of company i than the branch of company j.

Among the companies whose label is larger than i（range from i+1 to n）,and the branches whose label is larger than -i (range from -1 to –(i-1) ), there are c[i] units which have more workers than company i.

You need to sort the 2×N units in the ascending order by the number of workers.

The input contains multiple test cases. Each test case begins with a single line containing one integer N indicating the number of companies (0 < N ≤ 100000). Next line contains N integers which are c[1],c[2]…c[N] (c[i] ≤ N).

The input ends with N = 0.

The input ends with N = 0.

提交代码