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 <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vl b(n,0); b[0] = 1;
	if(n==2){
		cout << -1 << endl;
		return 0;
	}
	else if(n==3){
		map<ll,ll> mp;
		rep(i,3) mp[a[i]]++;
		bool flag = true;
		ll t;
		for(auto i : mp){
			if(i.second>=2){
				flag = false;
				t = i.first;
			}
		}
		if(!flag){
			b[0] = t;
			b[1] = a[t-1]^t;
			b[2] = b[0]^b[1];
		}else{
			b[0] = 1;
			b[1] = a[0]^1;
			b[2] = b[0]^b[1];
		}
	}
	else{
		set<ll> se;
		REP(i,2,n+1) se.insert(i);
		rep(i,n-4){
			auto itr = se.begin();
			if(*itr==a[b[i]-1]) itr++;
			b[i+1] = *itr;
			se.erase(itr);
		}
		vl nxt;
		for(auto i : se){
			nxt.push_back(i);
		}
		do{
			bool flag = true;
			REP(i,n-4,n-1){
				if(nxt[i-n+4]==a[b[i]-1]){
					flag = false;
					break;
				}else{
					b[i+1] = nxt[i-n+4];
				}
			}
			if(flag) break;
			else REP(i,n-3,n) b[i] = 0;
		}while(next_permutation(all(nxt)));
		if(b[n-1]==0){
			ll t = a[b[n-4]-1];
			ll mx = 0;
			for(ll i=n-4; i>=0; i--){
				if(a[b[i]-1]!=t){
					mx = i+1;
					break;
				}
				se.insert(b[i]);
				b[i] = 0;
			}
			b[mx] = t;
			se.erase(t);
			REP(i,mx,n-4){
				auto itr = se.begin();
				if(*itr==a[b[i]-1]) itr++;
				b[i+1] = *itr;
				se.erase(itr);
			}
			vl nxt;
			for(auto i : se){
				nxt.push_back(i);
			}
			do{
				bool flag = true;
				REP(i,n-4,n-1){
					if(nxt[i-n+4]==a[b[i]-1]){
						flag = false;
						break;
					}else{
						b[i+1] = nxt[i-n+4];
					}
				}
				if(flag) break;
				else REP(i,n-3,n) b[i] = 0;
			}while(next_permutation(all(nxt)));
		}
	}
	for(auto i : b) cout << i << " ";
	cout << endl;
}