Niwango has N cards, numbered 1,2,\ldots,N. He will now arrange these cards in a row.

Niwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below. To help him, determine whether such a way exists. If the answer is yes, also find the lexicographically smallest such arrangement.

* To the immediate right of Card 1 (if any) is NOT Card a_1.
* To the immediate right of Card 2 (if any) is NOT Card a_2.
* \vdots
* To the immediate right of Card N (if any) is NOT Card a_N.

Constraints

* 2 \leq N \leq 10^{5}
* 1 \leq a_i \leq N
* a_i \neq i

Input

Input is given from Standard Input in the following format:


N
a_1 a_2 \ldots a_N


Output

If no arrangements satisfy the conditions, print `-1`. If such arrangements exist, print the lexicographically smallest such arrangement, in the following format:


b_1 b_2 \ldots b_N


Here, b_i represents the i-th card from the left.

Examples

Input

4
2 3 4 1


Output

1 3 2 4


Input

2
2 1


Output

-1


Input

13
2 3 4 5 6 7 8 9 10 11 12 13 12


Output

1 3 2 4 6 5 7 9 8 10 12 11 13
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001

int N;
int A[maxn];
bool in[maxn];
int num[maxn];
set <pi> B;

int main(){
	fast;
	
	ifstream inp;
	inp.open("input.txt");
	
	cin>>N;
	mem(num,0);
	FOR(i,1,N) cin>>A[i],num[A[i]]++;
	
	if (N == 2 && A[1] == 2 && A[2] == 1){
		cout<<-1;
		return 0;
	}
	
	mem(in,1);
	
	set <int> S;
	FOR(i,1,N) S.insert(i),B.insert(pi(num[i],i));
	
	int prev = -1;
	vi ans;
	
	while (S.size() > 4){
		vi no;
		
		if ((*(--B.end())).f == S.size() - 1){
			int nxt = (*(--B.end())).s;
			ans.pb(nxt);
			S.erase(nxt);
	
			B.erase(pi(num[nxt],nxt));
			B.erase(pi(num[A[nxt]],A[nxt]));
			num[A[nxt]]--;
			B.insert(pi(num[A[nxt]],A[nxt]));
			
			in[nxt] = 0;
			prev = A[nxt];
			continue;
			
			
		}
		if (prev != -1 && in[prev]) no.pb(prev);
		
		aFOR(i,no){
			if (in[i]) S.erase(i);
		}
		

		int nxt = *S.begin();
		

		ans.pb(nxt);
		
		
		S.erase(nxt);
	
		B.erase(pi(num[nxt],nxt));
		B.erase(pi(num[A[nxt]],A[nxt]));
		num[A[nxt]]--;
		B.insert(pi(num[A[nxt]],A[nxt]));
		
		in[nxt] = 0;
		prev = A[nxt];
		aFOR(i,no){
			if (in[i]) S.insert(i);
		}
	}
		
		
	
	vi last;
	
	aFOR(i,S) last.pb(i);
	
	do{
		bool yes = 1;
		if (!ans.empty() && A[ans.back()] == last[0]) yes = 0;
		FOR(i,0,last.size() - 2){
			if (last[i+1] == A[last[i]]) yes = 0;
		}
		
		if (yes) break;
	}while (next_permutation(all(last)));
		
		
		
	
	
	aFOR(i,ans) cout<<i<<' ';
	aFOR(i,last) cout<<i<<' ';
				
				
	
}

