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> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int N; cin >> N;
	V<int> a(N);

	rep(i, N) {
		cin >> a[i];
		--a[i];
	}

	set<int> cand;
	rep(i, N) cand.insert(i);

	V<int> ans;

	int ng = -1;

	map<int, int> cnt;
	rep(i, N) ++cnt[a[i]];

	rep(t, N-8) {
		int nx = -1;
		for (auto &v : cand) {
			if (v == ng) continue;

			bool valid = 1;
			if (cnt.size() <= 2) {
				for (auto &p : cnt) if (p.se == N-1-t && p.fi != v) {
					valid = 0;
				}
			}

			if (!valid) {
				if (a[v] == ng) {
					puts("-1");
					return 0;
				}
				nx = a[v];
			} else {
				nx = v;
			}
			break;
		}

		if (nx == -1) {
			puts("-1");
			return 0;
		}

		cnt.erase(nx);
		if (cnt.count(a[nx]) && --cnt[a[nx]] == 0) {
			cnt.erase(a[nx]);
		}
		ng = a[nx];
		cand.erase(nx);
		ans.pb(nx);
	}

	V<int> pm(ALL(cand));

	bool ok = 0;
	do {
		bool t = 1;
		rep(i, pm.size()) {
			if (i == 0) {
				if (pm[0] == ng) t = 0;
			} else if (a[pm[i-1]] == pm[i]) {
				t = 0;
			}
		}
		ok |= t;
		if (t) {
			for (int p : pm) {
				ans.pb(p);
			}
			break;
		}
	} while (next_permutation(ALL(pm)));

	if (!ok) {
		puts("-1");
		return 0;
	}

	rep(i, N) {
		printf("%d%c", ans[i] + 1, i == N-1 ? '\n' : ' ');
	}

	return 0;
}