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 MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class segtree{
public:
	static const int N=1<<17;
	int dp[1<<18];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=min(dp[k*2+1],dp[k*2+2]);
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return 114514;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return min(vl,vr);
	}
};

int n;
int a[100005];
int cnt[100005];
int ans[100005];
int ord[100005];
set<int> se[100005];
segtree seg;

void solve2(){
	for(int i=0;i<n;i++){
		ord[i]=i;
		ans[i]=n;
	}
	do{
		bool flag=true;
		for(int i=0;i+1<n;i++){
			if(a[ord[i]]==ord[i+1]){
				flag=false;
				//printf("%d %d %d\n",i,a[ord[i]],ord[i+1]);
			}
		}
		//printf("%d %d %d %d %c\n",ord[0],ord[1],ord[2],ord[3],flag?'y':'n');
		if(flag){
			int fl=0;
			for(int i=0;i<n;i++){
				if(ord[i]<ans[i]){
					fl=1;
					break;
				}
				if(ord[i]>ans[i]){
					fl=-1;
					break;
				}
			}
			//printf("%d\n",fl);
			if(fl==1){
				for(int i=0;i<n;i++){
					ans[i]=ord[i];
				}
			}
		}
	}while(next_permutation(ord,ord+n));
}

bool used[100005];

void solve3(){
	vector<int> vec;
	for(int i=0;i<n;i++){
		if(!used[i]){
			vec.push_back(i);
		}
	} 
	for(int i=0;i<5;i++){
		ord[i]=vec[i];
	}
	for(int i=n-5;i<n;i++){
		ans[i]=n;
	}
	do{
		bool flag=true;
		if(a[ans[n-6]]==ord[0]){
			flag=false;
		}
		for(int i=0;i<5;i++){
			if(a[ord[i]]==ord[i+1]){
				flag=false;
			}
		}
		if(flag){
			int fl=0;
			for(int i=n-5;i<n;i++){
				if(ord[i-(n-5)]<ans[i]){
					fl=1;
					break;
				}
				if(ord[i-(n-5)]>ans[i]){
					fl=-1;
					break;
				}
			}
			if(fl==1){
				for(int i=n-5;i<n;i++){
					ans[i]=ord[i-(n-5)];
				}
			}
		}
	}while(next_permutation(ord,ord+5));
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		a[i]--;
		cnt[a[i]]++;
	}
	if(n==2){
		printf("-1\n");
		return 0;
	}
	if(n<=10){
		solve2();
	}else{
		for(int i=0;i<n;i++){
			se[cnt[i]].insert(i);
			seg.update(i,i);
		}
		int sz=n-1;
		for(int i=0;i<n-5;i++){
			int res=0;
			if(se[sz].size()>0){
				set<int>::iterator it=se[sz].begin();
				res=(*it);
			}else{
				int val=seg.query(0,n);
				//if(i>0)printf("%d %d\n",val,a[ans[i-1]]);
				if(i>0 && a[ans[i-1]]==val){
					val=seg.query(val+1,n);
				}
				res=val;
			}
			//printf("%d\n",res);
			se[cnt[res]].erase(res);
			sz--;
			se[cnt[a[res]]].erase(a[res]);
			cnt[a[res]]--;
			se[cnt[a[res]]].insert(a[res]);
			seg.update(res,114514);
			used[res]=true;
			ans[i]=res;
		}
		solve3();
	}
	for(int i=0;i<n;i++){
		printf("%d%c",ans[i]+1,i+1==n?'\n':' ');
	}
	return 0;
}
