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 <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> cnt(n, 1);
	rep(i, n) {
		cin >> p[i];
		p[i]--;
		cnt[p[i]]++;
	}
	vector<int> c = { 1,0 };
	if (p == c) {
		cout << "-1\n";
		return 0;
	}
	vector<set<int>> st(n + 1);
	rep(i, n) st[cnt[i]].insert(i);
	vector<int> ans;
	priority_queue<int, vector<int>, greater<int>> que;
	rep(i, n) que.push(i);
	int x = -1;
	int sz = n;
	while (sz > 3) {
		if (sz > 1 && st[sz].size() && x == -1) {
			int k = *st[sz].begin();
			ans.pb(k);
			st[cnt[k]].erase(k);
			cnt[k]--;
			st[cnt[p[k]]].erase(p[k]);
			cnt[p[k]]--;
			st[cnt[p[k]]].insert(p[k]);
			x = k;
		}
		else {
			int k = que.top(); que.pop();
			if (x == k) {
				k = que.top(); que.pop();
			}
			if (ans.size() == 0 || p[ans.back()] != k) {
				ans.pb(k);
				st[cnt[k]].erase(k);
				cnt[k]--;
				st[cnt[p[k]]].erase(p[k]);
				cnt[p[k]]--;
				st[cnt[p[k]]].insert(p[k]);
			}
			else {
				int nk = que.top(); que.pop();
				if (x == nk) {
					nk = que.top(); que.pop();
				}
				ans.pb(nk);
				st[cnt[nk]].erase(nk);
				cnt[nk]--;
				st[cnt[p[nk]]].erase(p[nk]);
				cnt[p[nk]]--;
				st[cnt[p[nk]]].insert(p[nk]);
				que.push(k);
			}
		}
		sz--;
	}
	vector<int> rem;
	while (!que.empty()) {
		int q = que.top(); que.pop();
		if (x != q) rem.pb(q);
	}
	sort(all(rem));
	do {
		bool flag = true;
		if (ans.size() > 0) {
			if (p[ans.back()] == rem[0]) flag = false;
		}
		rep(i, rem.size() - 1) if (p[rem[i]] == rem[i + 1]) flag = false;
		if (flag) {
			for (int i : rem) ans.pb(i);
			break;
		}
	} while (next_permutation(all(rem)));
	for (int i : ans) cout << i + 1 << ' ';
	cout << '\n';
}