This page is still under construction.

Parts of this page are still being built. What you see may change.

Permutation Making

Time limit1sMemory limit1024 MB

Summary
Construct a permutation A of 1..N so that its prefix sums mod N produce at most N/2+1 distinct values.
Level

Medium7 of 10

Topics
Math, Number theory, Greedy, Combinatorics
Solved
No attempts yet

Problem

A permutation of length NN is a sequence of NN natural numbers between 11 and NN in which no number appears more than once.

You are given a permutation AA of length NN.

Define the ii-th element of a new sequence PP as follows. (1≤i≤N1 \le i \le N)
Pi=(∑k=1iAk)  mod NP_i = \left(\sum_{k=1}^{i}A_k\right)\ \bmod N

Find any permutation AA for which the number of distinct values among the elements of PP is at most N2+1\frac{N}{2} + 1.

Input

The first line contains NN (1≤N≤100 0001 \le N \le 100\,000).

Output

Print A1A_1 through ANA_N, separated by spaces.

A permutation AA satisfying the condition always exists.

Examples1

  1. Example 1

    Input
    5
    
    Expected output
    3 2 4 5 1