PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000109. Hoán vị vui nhộn (Fun Permutation)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Hoán vị vui nhộn (Fun Permutation)

Fun Permutation

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given a permutation pp of 1,2,…,n1,2,\dots,n, construct another permutation qq so that gcd⁡(pi+qi, pi+1+qi+1)≥3\gcd(p_i+q_i,\ p_{i+1}+q_{i+1})\ge3 for all 1≤i<n1\le i<n. A solution always exists; output any valid permutation.

Input

The first line contains nn. The second line contains permutation p1,p2,…,pnp_1,p_2,\dots,p_n.

Output

Print the nn elements of a valid permutation qq.

Subtasks

  • Subtask 1 (20 points): 2≤n≤102\le n\le10.
  • Subtask 2 (30 points): 2≤n≤20002\le n\le2000.
  • Subtask 3 (50 points): 2≤n≤2⋅1052\le n\le2\cdot10^5.

Examples

Input

3
1 3 2

Output

3 1 2

Explanation

Every sum pi+qip_i+q_i equals 44, so every adjacent pair of sums has GCD 4≥34\ge3.