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 <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, a[100010];
multiset<int> st;
set<int> st2;
bool bl[100010];
vector<int> ans;

signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i], st.insert(a[i]), st2.insert(i);
	if (n == 2) {
		cout << -1 << endl;
		return 0;
	}
	int p = 0, q = 0;
	for (int i = 2; i < n; i++) {
		if (*st.begin() == *--st.rbegin() && !bl[*st.begin()]) {
			ans.push_back(*st.begin());
			q = p;
			p = a[*st.begin()];
			bl[*st.begin()] = true;
			st2.erase(*st.begin());
			st.erase(st.lower_bound(a[*st.begin()]));
		}
		else if (*++st.begin() == *st.rbegin() && !bl[*st.rbegin()]) {
			ans.push_back(*st.rbegin());
			q = p;
			p = a[*st.rbegin()];
			bl[*st.rbegin()] = true;
			st2.erase(*st.rbegin());
			st.erase(st.lower_bound(a[*st.rbegin()]));
		}
		else {
			auto s = st2.begin();
			if (p == *s)s++;
			ans.push_back(*s);
			q = p;
			p = a[*s];
			bl[*s] = true;
			st.erase(st.lower_bound(a[*s]));
			st2.erase(s);
		}
	}
	int s = *st2.begin(), t = *st2.rbegin(), r = ans.back();
	if (a[s] == t && a[t] == s) {
		ans.pop_back();
		if (q == s)ans.push_back(t), ans.push_back(r), ans.push_back(s);
		else ans.push_back(s), ans.push_back(r), ans.push_back(t);
	}
	else {
		if (p == s)ans.push_back(t), ans.push_back(s);
		else ans.push_back(s), ans.push_back(t);
	}
	for (int i = 0; i < (int)ans.size(); i++)cout << ans[i] << " ";
	cout << endl;
}
