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
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int AS = 1 << 17;
ll dat[2 * AS];
const ll are = 1 << 30;
void modify(int p) {
	for (dat[p += AS] -= are; p > 1; p >>= 1) dat[p >> 1] = max(dat[p], dat[p ^ 1]);
}
void modify0(int p) {
	for (dat[p += AS] = 0; p > 1; p >>= 1) dat[p >> 1] = max(dat[p], dat[p ^ 1]);
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int A[100000];
	rep(i, N) {
		A[i] = getint() - 1;
		dat[AS + A[i]]++;
	}
	rep(i, N) dat[AS + i] = (dat[AS + i] << 30) + i;
	for (int i = AS - 1; i > 0; i--) dat[i] = max(dat[i << 1], dat[i << 1 | 1]);

	if (N == 2) {
		printf("-1");
		return 0;
	}

	int dame = -1;
	int j = 0;
	const int m = (1 << 30) - 1;
	bool used[100000] = {};
	bool iranai = 0;
	rep(i, N - 3) {
		int kotae;
		if (!iranai && N - i - 1 == dat[1] >> 30) {
			kotae = dat[1] & m;
			iranai = 1;
		}
		else {
			int k = j;
			while (used[k] || k == dame) k++;
			kotae = k;
		}
		putint(kotae + 1);
		used[kotae] = 1;
		dame = A[kotae];
		while (used[j]) j++;
		if (!iranai) modify(dame);
		//modify0(kotae);

		//これを入れないと正しくなさそうだけど
		//嘘でも通るならいいかなって・・・
		//5
		//2 3 1 1 1
		//とか壊れてる
	}

	int kouho[3];
	int k = 0;
	for (int i = j; i < N; i++) {
		if (!used[i]) kouho[k++] = i;
	}
	while (1) {
		if (dame != kouho[0] && A[kouho[0]] != kouho[1] && A[kouho[1]] != kouho[2]) break;
		next_permutation(kouho, kouho + 3);
	}
	putint(kouho[0] + 1);
	putint(kouho[1] + 1);
	putint(kouho[2] + 1);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}