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 FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (100006)
ll n, A[MAXN], cnt[MAXN];
set<int> s[MAXN];
set<int> av;
int main()
{
	FAST
	cin>>n;
	FOR(i,1,n)cin>>A[i], ++cnt[A[i]];
	if(n==2) {
		cout<<"-1\n";
		return 0;
	}
	FOR(i,1,n)s[cnt[i]].ins(i), av.ins(i);
	vector<ll> v;
	while(n-siz(v) > 3) {
		ll V = n-siz(v);
		ll tp = -1;
		assert(siz(s[V])==0);
		if(siz(s[V-1])) {
			tp = *s[V-1].begin();
		} else {
			if(v.empty() || A[v.back()] != *av.begin()) {
				tp = *av.begin();
			} else {
				tp = *++av.begin();
			}
		}
		assert(~tp);
		v.pb(tp);
		av.erase(tp);
		s[cnt[tp]].erase(tp);
		if(av.find(A[tp]) != av.end()) {
			s[cnt[A[tp]]].erase(A[tp]);
			-- cnt[A[tp]];
			s[cnt[A[tp]]].ins(A[tp]);
		}
	}
	assert(n-siz(v)==3);
	/* next permutation here */
	vector<ll> hey = {*av.begin(), *++av.begin(), *++++av.begin()};
	sort(all(hey));
	do {
		v.pb(hey[0]), v.pb(hey[1]), v.pb(hey[2]);
		bool fk=1;
		FOR(i,max(0ll,n-4),n-2) if(A[v[i]] == v[i+1]) {
			fk=0;
		}
		if(fk) break;
		v.pop_back(), v.pop_back(), v.pop_back();
	} while(next_permutation(all(hey)));
	/* */
	assert(v.size()==n); for(auto i:v) cout<<i<<' '; cout<<'\n'; 
}
