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 <set>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

template<typename Type> class RangeMin {
private:
	int size_;
	std::vector<Type> dat;
public:
	RangeMin() : size_(0), dat(std::vector<Type>()) {};
	RangeMin(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat.resize(size_ << 1, std::numeric_limits<Type>::max());
	}
	template<class T>
	RangeMin(T begin_, T end_) {
		int n = end_ - begin_;
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
		for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
		for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
	}
	inline unsigned size() { return size_; }
	inline void update(int i, Type x) {
		i += size_; dat[i] = x;
		while (i > 1) {
			i >>= 1;
			dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	inline Type query(int l, int r) {
		Type ret = std::numeric_limits<Type>::max();
		l += size_; r += size_;
		while (l != r) {
			if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1;
			if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1;
		}
		return ret;
	}
};

int N, A[1 << 18], B[1 << 18], C[1 << 18], cnt[1 << 18];
set<int> Set;
pair<int, int> v = make_pair(-1, -1);
RangeMin<long long> X;

void sousa(int pos, int val) {
	B[pos] = val;
	cnt[A[val]]--;
	X.update(A[val], -(1000000LL * cnt[A[val]] + 1LL * A[val]));
	Set.erase(val);
}

void sousa_reverse(int pos, int val) {
	B[pos] = 0;
	cnt[A[val]]++;
	X.update(A[val], -(1000000LL * cnt[A[val]] + 1LL * A[val]));
	Set.insert(val);
}

bool dfs(int pos) {
	if (pos == N + 1) {
		return true;
	}

	if (pos < N - 2) {
		long long V = X.query(1, N + 1); V *= -1;
		long long VA = V / 1000000, VB = V % 1000000;
		if (VA == (N - pos)) {
			sousa(pos, VB);
			bool I = dfs(pos + 1);
			if (I == true) return true;
			sousa_reverse(pos, VB);
			return false;
		}
	}

	int v = 0;
	while (true) {
		auto itr = Set.lower_bound(v);
		if (itr == Set.end()) break;
		if ((*itr) == A[B[pos - 1]]) {
			v = (*itr) + 1;
			continue;
		}

		int val = (*itr);

		v = val + 1;
		sousa(pos, val);
		bool I = dfs(pos + 1);
		if (I == true) return true;
		sousa_reverse(pos, val);
	}
	return false;
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> A[i]; cnt[A[i]]++; }
	for (int i = 1; i <= N; i++) Set.insert(i);
	X = RangeMin<long long>(N + 2);
	for (int i = 1; i <= N; i++) X.update(i, -(1000000LL * cnt[i] + 1LL * i));

	dfs(1);
	if (B[1] >= 1) {
		for (int i = 1; i <= N; i++) {
			if (i >= 2) cout << " ";
			cout << B[i];
		}
		cout << endl;
	}
	else {
		cout << "-1" << endl;
	}
	return 0;
}