#P1157E. Minimum Array

    ID: 4532 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>binary searchdata structuresgreedy*1700

Minimum Array

Description

You are given two arrays aa and bb, both of length nn. All elements of both arrays are from 00 to n1n-1.

You can reorder elements of the array bb (if you want, you may leave the order of elements as it is). After that, let array cc be the array of length nn, the ii-th element of this array is ci=(ai+bi)%nc_i = (a_i + b_i) \% n, where x%yx \% y is xx modulo yy.

Your task is to reorder elements of the array bb to obtain the lexicographically minimum possible array cc.

Array xx of length nn is lexicographically less than array yy of length nn, if there exists such ii (1in1 \le i \le n), that xi<yix_i < y_i, and for any jj (1j<i1 \le j < i) xj=yjx_j = y_j.

The first line of the input contains one integer nn (1n21051 \le n \le 2 \cdot 10^5) — the number of elements in aa, bb and cc.

The second line of the input contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (0ai<n0 \le a_i < n), where aia_i is the ii-th element of aa.

The third line of the input contains nn integers b1,b2,,bnb_1, b_2, \dots, b_n (0bi<n0 \le b_i < n), where bib_i is the ii-th element of bb.

Print the lexicographically minimum possible array cc. Recall that your task is to reorder elements of the array bb and obtain the lexicographically minimum possible array cc, where the ii-th element of cc is ci=(ai+bi)%nc_i = (a_i + b_i) \% n.

Input

The first line of the input contains one integer nn (1n21051 \le n \le 2 \cdot 10^5) — the number of elements in aa, bb and cc.

The second line of the input contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (0ai<n0 \le a_i < n), where aia_i is the ii-th element of aa.

The third line of the input contains nn integers b1,b2,,bnb_1, b_2, \dots, b_n (0bi<n0 \le b_i < n), where bib_i is the ii-th element of bb.

Output

Print the lexicographically minimum possible array cc. Recall that your task is to reorder elements of the array bb and obtain the lexicographically minimum possible array cc, where the ii-th element of cc is ci=(ai+bi)%nc_i = (a_i + b_i) \% n.

Sample Input 1

4
0 1 2 1
3 2 1 1

Sample Output 1

1 0 0 2

Sample Input 2

7
2 5 1 5 3 4 3
2 4 3 5 6 5 1

Sample Output 2

0 0 0 1 0 2 4