#include "partition.h"
#include <bits/stdc++.h>

using namespace std;

map <int, int> mp;

std::vector<int> solve(std::vector<int> A) {
	
	int n;
	cin >> n;
	
	vector <int> a = A;
	
	int sb1 = 0;
	bool sb2, sb3, sb4;
	sb2 = sb3 = sb4 = true;
	
	vector <int> answer( n );
	
	for ( long long i = 0; i < n; i++ ) {
		
		mp[a[i]]++;
		
		if ( mp[a[i]] % 2 == 0 ) {
			sb1--;
		} else {
			sb1++;
		}
		
		if ( a[i] != ( 1LL << i ) ) {
			sb2 = false;
		}
		
		if ( a[i] != i + 1 ) {
			sb4 = false;
		}
		
		answer[i] = i;
		
	}
	
	if ( sb1 == 0 ) {
		
		int l = 0, r = n - 1;
		
		mp.clear();
		
		for ( int i = 0; i < n; i++ ) {
			
			mp[a[i]]++;
			
			if ( mp[a[i]] % 2 == 1 ) {
				
				answer[l] = i;
				
			} else {
				
				answer[r] = i;
				
			}
			
		}
		
	} else if ( sb2 == true ) {
	
		answer[0] = n - 1;
		
		for ( int i = 0; i < n - 1; i++ ) {
			
			answer[i + 1] = i;
			
		}
	
	} else if ( sb4 == true ) {
		
		for ( int i = 0; i < n; i++ ) {
			
			if ( i % 2 == 0 ) {
				
				answer[i] = i;
				
			} else {
				
				answer[i] = n - i;
				
			}
			
		}
		
	}
	
	return answer;
	
}
/*
extern vector<int> solve(vector<int> A);
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t ;
    for (int test=1; test<=t; test++) {
        int n;
        cin >> n ;
        vector <int> a(n);
        for (int i=0; i<n; i++) {
            cin >> a[i] ;
        }

        vector <int> ind = solve( a );
        
        for ( int i = 0; i < n; i++ ) {
        	
        	cout << ind[i] << " ";
        	
		}
        
        cout << endl ;
    }
    cout << endl ;
    return 0;
}/*