Under construction

Still being built. Things may change

Level Design

Time limit1sMemory limit1024 MB

Summary
Permute the values 1 to N over rooms 1 to N to minimize the largest non-adjacent subset sum, then print the permutation and that minimum.
Level

Medium7 of 10

Topics
Greedy, Dynamic programming, Array
Solved
No attempts yet

Problem

The time limit is 1000 ms and the memory limit is 1024 MB.

There are N+2N+2 levels numbered from 00 to N+1N+1. The levels are arranged in the order 0,1,2,⋯ ,N,N+10, 1, 2, \cdots, N, N+1, and the player starts at level 00 and advances in order until level N+1N+1. The player cannot return to a level already visited or skip a level.

Except for room 00 and room N+1N+1, each of the NN rooms holds one item that adds points. If the player takes the item in room ii, the player gains ii points. In each level, the player decides whether to carry the item, but the player cannot carry items in two consecutive levels.

Byungyoon wants to rearrange the items so that the maximum score the player can earn is as small as possible. The rearrangement must satisfy the following conditions.

  • Rooms 1,2,⋯ ,N1, 2, \cdots, N each contain exactly one item.
  • Let SiS_i be the score of the item in room ii after the rearrangement. S1,S2,⋯ ,SNS_1, S_2, \cdots, S_N must be a permutation in which each integer from 11 to NN appears exactly once.

Find one arrangement of items that satisfies these conditions, and find the maximum score the player can earn with that arrangement.

Input

The first line contains an integer NN. (1≤N≤200 0001 \le N \le 200\ 000)

Output

The first line prints S1,S2,⋯ ,SNS_1, S_2, \cdots, S_N separated by spaces.

The second line prints the maximum score the player can earn with that arrangement.

If several arrangements satisfy the conditions, any of them is accepted.

Examples1

  1. Example 1

    Input
    3
    
    Expected output
    1 3 2
    3