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<(n);i++)

using namespace std;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(int n):a(n){}
	void add(int i,G val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(val<=G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<=val) val-=a[x+k-1], x+=k;
		return x;
	}
};

int n,bad[100000],deg[100000],ans[100000];

set<pair<int,int>> Deg;
Fenwick_tree<int> F(0);

bool dfs(int i){
	if(i==n) return true;

	int x=Deg.rbegin()->second;
	if(deg[x]==n-i-1){
		if(i==0 || bad[ans[i-1]]!=x){
			int y=bad[x];
			bool b=F.sum(y,y+1);

			Deg.erase({deg[x],x});
			if(b){
				Deg.erase({deg[y],y});
				deg[y]--;
				Deg.emplace(deg[y],y);
			}
			F.add(x,-1);

			ans[i]=x;
			if(dfs(i+1)) return true;

			F.add(x,1);
			if(b){
				Deg.erase({deg[y],y});
				deg[y]++;
				Deg.emplace(deg[y],y);
			}
			Deg.emplace(deg[x],x);
		}
		return false;
	}

	for(int p=1;;p++){
		int x=F.lower_bound(p);
		if(x==n) break;
		if(i==0 || bad[ans[i-1]]!=x){
			int y=bad[x];
			bool b=F.sum(y,y+1);

			Deg.erase({deg[x],x});
			if(b){
				Deg.erase({deg[y],y});
				deg[y]--;
				Deg.emplace(deg[y],y);
			}
			F.add(x,-1);

			ans[i]=x;
			if(dfs(i+1)) return true;

			F.add(x,1);
			if(b){
				Deg.erase({deg[y],y});
				deg[y]++;
				Deg.emplace(deg[y],y);
			}
			Deg.emplace(deg[x],x);
		}
	}
	return false;
}

int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%d",&bad[i]), bad[i]--;

	rep(i,n) deg[bad[i]]++;
	rep(i,n) Deg.emplace(deg[i],i);

	F=Fenwick_tree<int>(n);
	rep(i,n) F.add(i,1);

	if(dfs(0)){
		rep(i,n) printf("%d%c",ans[i]+1,i<n-1?' ':'\n');
	}
	else{
		puts("-1");
	}

	return 0;
}
