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<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[110000],cnt[110000];
vector<int> vs,v1;
int n,m;

bool check(int p){
	int i,j;
	int a,b,c;
	set<int> s1;
	if(p==m){
		for(i=(int)vs.size()-m;i<(int)vs.size();i++){
			if(s1.find(vs[i])!=s1.end())return false;
			s1.insert(vs[i]);
			if(i && t[vs[i-1]]==vs[i])return false;
		}
		return true;
	}
	for(i=0;i<v1.size();i++){
		vs.push_back(v1[i]);
		if(check(p+1))return true;
		vs.pop_back();
	}
	return false;
}

int main(){
	int i,j,k;
	int a,b,c;
	const int M=5;
	set<int> s1;
	cin>>n;
	for(i=0;i<n;i++){
		s1.insert(i);
	}
	for(i=0;i<n;i++){
		cin>>t[i];
		t[i]--;
		cnt[t[i]]++;
	}
	t[n]=-1;
	if(n>M){
		for(i=0;i<n-M;i++){
			if(!vs.empty())a=vs.back();
			else a=n;
			auto itr=s1.begin();
			b=*itr,c=t[b];
			if(cnt[b]<cnt[c])swap(b,c);
			if(cnt[b]==n-i-1){
				vs.push_back(b);
				s1.erase(b);
				cnt[t[b]]--;
				continue;
			}
			if(*itr==t[a])itr++;
			b=*itr;
			vs.push_back(*itr);
			s1.erase(itr);
			cnt[t[b]]--;
		}
	}
	for(auto node:s1)v1.push_back(node);
	sort(v1.begin(),v1.end());
	m=v1.size();
	if(check(0)){
		for(i=0;i<n;i++)vs[i]++;
		array_show(vs);
	}else cout<<-1<<endl;
}