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;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int N, ng, a[100010], ans[100010];
PQS(int) pq;

void OUT(void){
	rep(index, N) cout << ans[index] << " ";
	cout << "\n";
}

int main(){
	cin >> N;
	rep(i, N){ cin >> a[i+1]; pq.push(i+1); }
	if(N==2){ cout << -1 << endl; return 0; }
	if(N==3){
		vector<int> aa = {1, 2, 3};
		do{
			if(a[aa[0]] != aa[1] && a[aa[1]] != aa[2]){
				cout << aa[0] << " " << aa[1] << " " << aa[2] << "\n";
				return 0;
			}
		}while(next_permutation(all(aa)));
	}
	rep(i, N-1){
		if(i==0){ ans[i] = 1; pq.pop(); }
		else{
			int t = pq.top(); pq.pop();
			if(t == a[ans[i-1]]){
				ans[i] = pq.top(); pq.pop();
				pq.push(t);
			}else ans[i] = t;
		}
	}
	ans[N-1] = pq.top(); pq.pop();
	if(a[ans[N-2]] != ans[N-1]){ OUT(); return 0; }
	if(a[ans[N-3]] != ans[N-1] && a[ans[N-1]] != ans[N-2]){
		swap(ans[N-2], ans[N-1]); OUT(); return 0;
	}
	for(int i=N-4; i>=0; i--){
		if(i==N-4){
			ng = a[ans[i]];
			vector<int> aa = {ans[N-3], ans[N-2], ans[N-1]};
			sort(all(aa));
			do{
				if(ng != aa[0] && a[aa[0]] != aa[1] && a[aa[1]] != aa[2]){
					rep(j, N-3) cout << ans[j] << " ";
					cout << aa[0] << " " << aa[1] << " " << aa[2] << "\n";
					return 0;
				}
			}while(next_permutation(all(aa)));
			for(int j=N-3; j<N; j++){
				if(ans[j] != ng) pq.push(ans[j]);
				if(ans[j] != ng && a[ans[j]] != ng){
					int n1 = ans[N-2]+ans[N-1]-ng;
					int n2 = ans[N-3];
					if(n2 > ng) swap(n2, ng);
					ans[N-3] = n1, ans[N-2] = n2, ans[N-1] = ng;
					if(a[ans[N-3]] != ans[N-2] && a[ans[N-2]] != ans[N-1]){
						OUT(); return 0;
					}
					swap(ans[N-2], ans[N-1]);
					OUT(); return 0;
				}
			}
			pq.push(ans[i]);
		}else{
			if(a[ans[i]] != ng){
				ans[i+1] = ng;
				rep(j, N-i-2){
					int t = pq.top(); pq.pop();
					if(j != 0){ ans[j+i+2] = t; continue; }
					if(a[ans[i+1]] != t) ans[i+2] = t;
					else{
						ans[i+2] = pq.top(); pq.pop();
						pq.push(t);
					}
				}
				OUT();
				return 0; 
			}
			pq.push(ans[i]);
		}
	}
	ans[0] = ng;
	rep(i, N-1){
		int t = pq.top(); pq.pop();
		if(i != 0){ ans[i+1] = t; continue; }
		if(a[ans[i]] != t) ans[i+1] = t;
		else{
			ans[i+1] = pq.top(); pq.pop();
			pq.push(t);
		}
	}
	OUT();
	return 0;
}
