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;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define print(x,n) for(int i_ = 0;i_ < n;i_++) printf("%lld%c",x[i_]," \n"[i_ == n - 1])

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

int n,a[100010],ans[100010];

vector<int> check(set<int> s,int t){
	vector<int> v;
	for(int x : s) v.push_back(x);
	do{
		int p = t;
		bool isOK = true;
		for(int i = 0;i < 3;i++){
			if(p == v[i]) isOK = false;
			p = a[v[i]];
		}
		if(isOK){
			return v;
		}
	}while(next_permutation(all(v)));
}

signed main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i]; a[i]--;
	}
	if(n == 2){
		if(a[0] == 1 && a[1] == 0) cout << -1 << endl;
		else if(a[0] == 1) cout << "2 1" << endl;
		else cout << "1 2" << endl;
		return 0;
	}
	int cnt[100010] = {};
	priority_queue<P> que;
	for(int i = 0;i < n;i++){
		if(i != a[i]) cnt[a[i]]++;
	}
	for(int i = 0;i < n;i++){
		que.emplace(cnt[i],i);
	}
	int prv = -1;
	set<int> unused;
	for(int i = 0;i < n;i++) unused.insert(i);
	for(int i = 0;i < n - 3;i++){
		while(!unused.count(que.top().second) || cnt[que.top().second] != que.top().first) que.pop();
		P p = que.top();
		if(p.first == n - i - 1){
			ans[i] = p.second;
		}else{
			auto it = unused.begin();
			if(*it == prv) it++;
			ans[i] = *it;
		}
		prv = a[ans[i]];
		if(ans[i] != a[ans[i]]) cnt[a[ans[i]]]--;
		que.emplace(cnt[a[ans[i]]],a[ans[i]]);
		unused.erase(ans[i]);
	}
	vector<int> v = check(unused,prv);
	for(int i = 0;i < 3;i++) ans[n - 3 + i] = v[i];
	for(int i = 0;i < n;i++) ans[i]++;
	print(ans,n);
}