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;

typedef pair<int,int> P;

#define fr first
#define sc second

int main(){
	static int n;
	static int a[100010];
	static int p[100010];
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i ++){
		scanf("%d",&a[i]);
	}
	if(n == 2){
		puts("-1");
		return 0;
	}
	if(n <= 10){
		int q[12];
		for(int i = 0 ; i < n ; i ++){
			q[i] = i+1;
		}
		do{
			for(int i = 1 ; i <= n ; i ++){
				p[i] = q[i-1];
			}
			bool ret = true;
			for(int i = 1 ; i+1 <= n ; i ++){
				ret &= a[p[i]] != p[i+1];
			}
			if(ret){
				for(int j = 1 ; j <= n ; j ++){
					printf("%d%c",p[j],(j==n)?'\n':' ');
				}
				return 0;
			}
		}while(next_permutation(q,q+n));
	}
	
	static int cnt[100010];
	//static bool used[100010];
	static set<int> S;
	for(int i = 1 ; i <= n ; i ++){
		cnt[a[i]] ++;
		//used[i] = false;
		S.insert(i);
	}
	priority_queue<P> que;
	for(int i = 1 ; i <= n ; i ++){
		que.push(P(cnt[i],i));
	}
	
	for(int i = 1 ; i <= n-10 ; i ++){
		while(que.top().fr >= n-i){
			P q = que.top(); que.pop();
			if(cnt[q.sc] == n-i){
				p[i] = q.sc;
				S.erase(q.sc);
				//used[q.sc] = true;
				int loc = i+1;
				for(set<int>::iterator itr = S.begin() ; itr != S.end() ; itr++){
					p[loc] = *itr;
					loc ++;
				}
				/*vector<int> vec;
				for(int j = 1 ; j <= n ; j ++){
					if(!used[j])vec.push_back(j);
				}
				for(int j = 0 ; j < vec.size() ; j ++){
					p[i+1+j] = vec[j];
				}*/
				if(a[q.sc] == *S.begin()){
					swap(p[i+1],p[i+2]);
				}
				for(int j = 1 ; j <= n ; j ++){
					printf("%d%c",p[j],(j==n)?'\n':' ');
				}
				return 0;
			}
		}
		if(i == 1 || a[p[i-1]] != *S.begin()){
			p[i] = *S.begin();
			S.erase(S.begin());
		}
		else {
			set<int>::iterator itr = S.begin();
			itr++;
			p[i] = *itr;
			S.erase(itr);
		}
		cnt[p[i]] = 0;
		cnt[a[p[i]]]--;
		que.push(P(cnt[a[p[i]]],a[p[i]]));
	}
	
	int q[10];
	int ind = 0;
	for(set<int>::iterator itr = S.begin() ; itr != S.end() ; itr ++){
		q[ind] = *itr;
		ind ++;
	}
	do{
		for(int i = 0 ; i < 10 ; i ++){
			p[n-9+i] = q[i];
		}
		bool ret = true;
		for(int i = 0 ; i < 10 ; i ++){
			if(n-10+i == 0)continue;
			ret &= a[p[n-10+i]] != p[n-9+i];
		}
		if(ret){
			for(int j = 1 ; j <= n ; j ++){
				printf("%d%c",p[j],(j==n)?'\n':' ');
			}
			return 0;
		}
	}while(next_permutation(q,q+10));
}