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

#GD0000142. Hoán vị đẹp (Pretty Permutations)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Hoán vị đẹp (Pretty Permutations)

Pretty Permutations

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn cats in positions 1,…,n1,\ldots,n, initially with cat ii at position ii. Rearrange them so that no cat remains at its original position. If cat pip_i ends up at position ii, the total traveled distance is ∑i=1n∣pi−i∣\sum_{i=1}^{n}|p_i-i|.

Output a permutation with no fixed points that minimizes this distance. Any optimal permutation is accepted.

Input

The input contains one integer nn.

Output

Print nn integers forming a permutation pp of 1,…,n1,\ldots,n, with pi≠ip_i\ne i and minimum total displacement.

Subtasks

  • Subtask 1 (20 points): 2≤n≤202\le n\le20.
  • Subtask 2 (30 points): 2≤n≤402\le n\le40.
  • Subtask 3 (50 points): 2≤n≤1002\le n\le100.

Examples

Input

5

Output

2 1 4 5 3

Explanation

For n=5n=5, the permutation 2,1,4,5,32,1,4,5,3 moves every cat. The total distance is 1+1+1+1+2=61+1+1+1+2=6, which is minimum for an odd number of cats.