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>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	V<int> to(N);
	rep(i,N){
		cin >> to[i];
		to[i]--;
	}
	V<int> d(N);
	rep(i,N) d[to[i]]++;
	V<int> ans(N,-1);
	int ban = -1;
	set<int> st; rep(i,N) st.insert(i);

	auto ANSWER = [&](){
		rep(i,N) cout << ans[i]+1 << " ";
		cout << endl;
		exit(0);
	};
	auto NO = [&](){
		cout << -1 << endl;
		exit(0);
	};

	rep(i,N){
		if(N-i <= 8){
			V<int> vs(all(st));
			do{
				bool ok = true;
				if(vs[0] == ban) ok = false;
				int K = vs.size();
				rep(i,K-1) if(to[vs[i]] == vs[i+1]) ok = false;
				if(ok){
					rep(j,K) ans[i+j] = vs[j];
					ANSWER();
				}
			}while(next_permutation(all(vs)));
			NO();
		}
		int K = N-i;
		for(int v: st){
			if(v == ban) continue;
			if(st.count(to[v]) && d[to[v]] == K-1) continue;
			ans[i] = v;
			st.erase(v);
			ban = to[v];
			d[to[v]]--;
			break;
		}
		if(ans[i] == -1){
			assert(i == 0);
			NO();
		}
	}
	rep(i,N) cout << ans[i]+1 << " ";
	cout << endl;
}
