#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

std::vector<int> solve(std::vector<int> A) {
    int n = A.size();
    int formula = (n*(n+1))/2;
    vi a(n);
    if (n==1) {
        return {1};
    }else if (n==2) {
        return {2, 1};
    }
    if (formula%2 == 0) {
        if (n%2 == 0) { // Prv slucaj (nizata zavrsuva na paren broj)
            for (int i = 0;i<n;i+=2) {
                a[i] = i;
                a[n-i-1] = i+1;
            }
        }else {
            a[n-1] = A[n-1]-1; // Vtor slucaj niza e neparna i sumata e delliva so 2
            for (int i = 0;i<n-1;i+=2) {
                a[i] = i;
                a[n-i-2] = i+1;
            }
        }
    }else {
        a[n-1] = A[n-1] - 1; // Tret
        a[n-2] = A[(n-1)/2] - 1;
        for (int i = 0;i<n-2;i+=2) {
            a[i] = i;
            a[n-i-2] = i+1;
        }
    }
    return a;
}