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

#GD0000155. Xây dựng mảng (Constructing the Array)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Xây dựng mảng (Constructing the Array)

Constructing the Array

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Start with an array of nn zeros. Perform nn operations numbered 11 through nn. At operation ii, choose a longest contiguous segment consisting only of zeros; among equal-length segments choose the leftmost.

If the chosen segment is [l,r][l,r], write ii at position ⌊(l+r)/2⌋\lfloor(l+r)/2\rfloor, taking the left middle position when the length is even. Output the resulting array after all operations.

Input

The input contains one integer nn.

Output

Print the nn array elements after the described operations.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le30.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le3000.
  • Subtask 3 (50 points): 1≤n≤2⋅1051\le n\le2\cdot10^5.

Examples

Input

5

Output

2 4 1 3 5

Explanation

For n=5n=5, first place 11 at position 33. The two length-two zero segments are [1,2][1,2] and [4,5][4,5], so place 22 at position 11, then 33 at position 44. Finally put 44 at position 22 and 55 at position 55. The answer is 2,4,1,3,52,4,1,3,5.