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>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int SZ> struct Counter {
	int Count[SZ];
	set<int> Kinds;
	Counter() { rep(i, 0, SZ) Count[i] = 0; }

	void Increment(int i) {
		if (Count[i] == 0) Kinds.insert(i);
		Count[i]++;
	}

	void Decrement(int i) {
		Count[i]--;
		if (Count[i] == 0) Kinds.erase(i);
	}
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[101010];
int limit = 8;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) A[i]--;

	int originalN = N;

	vector<int> ans;
	set<int> unused;
	rep(i, 0, N) unused.insert(i);
	
	Counter<101010> counter;
	rep(i, 0, N) counter.Increment(A[i]);

	while (limit < N) {
		if (counter.Kinds.size() == 2) {
			auto ite = counter.Kinds.begin();

			int x = *ite; ite++;
			int y = *ite;

			if (counter.Count[x] == N - 1) {
				if (unused.count(x)) {
					ans.push_back(x);
					N--;
					unused.erase(x);
					counter.Decrement(A[x]);
					continue;
				}
			}

			if (counter.Count[y] == N - 1) {
				if (unused.count(y)) {
					ans.push_back(y);
					N--;
					unused.erase(y);
					counter.Decrement(A[y]);
					continue;
				}
			}
		}

		auto ite = unused.begin();

		if (0 < ans.size() and A[ans.back()] == *ite) ite++;
		ans.push_back(*ite);
		N--;
		counter.Decrement(A[*ite]);
		unused.erase(*ite);
	}

	vector<int> rest;
	rep(i, 0, N) {
		int x = *unused.begin();
		rest.push_back(x);
		unused.erase(x);
	}

	do {
		if (0 < ans.size() and A[ans.back()] == rest[0]) continue;
		bool ok = true;
		rep(i, 0, N - 1) if (A[rest[i]] == rest[i + 1]) ok = false;
		if (ok) {
			rep(i, 0, N) ans.push_back(rest[i]);
			break;
		}
	} while (next_permutation(all(rest)));

	if (ans.size() != originalN) {
		cout << -1 << endl;
		return;
	}

	rep(i, 0, originalN) {
		if(i) printf(" ");
		printf("%d", ans[i] + 1);
	}
	printf("\n");
}





