A Permutation Problem

View as PDF

Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

A permutation P of length N is the sequence P_1, P_2, \ldots, P_N, consisting of N distinct integers, each of them in the range [1, N].

A sketchy permutation is a permutation P such that for all integer i (1 \le i \le N), it satisfies constraint that P_{P_i} = N - i + 1.

You have the integer N. Find some sketchy permutation P of length N.

Input Specification

The first line will contain the integer N (1 \le N \le 10^5), the required permutation length.

Output Specification

Print -1 if the sketchy permutation P of length N does not exist.

Otherwise, print N distinct integers P_1, P_2, \ldots, P_N (1 \le P_i \le N), the required permutation.

If there are multiple such permutations, print the lexicographically smallest one.

Sample Input 1

1

Sample Output 1

1

Sample Input 2

5

Sample Output 2

2 5 3 1 4

Sample Input 3

2

Sample Output 3

-1

Comments

There are no comments at the moment.