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>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int p[MAXN];
int cnt[MAXN];

int ans[MAXN];

set<int> st;
set<pii> stp;

int used[MAXN];

int top;

void add(int v) {
	st.erase(v);
	stp.erase(mp(cnt[v], v));
	
	used[v] = 1;
	ans[top] = v;
	top++;
	
	stp.erase(mp(cnt[p[v]], p[v]));
	cnt[p[v]]--;
	if (!used[p[v]]) {
		stp.insert(mp(cnt[p[v]], p[v]));
	}
}

void solve(){
	int n;
	scanf("%d", &n);
	
	if (n == 2) {
		printf("-1\n");
		return;
	}
	
	REPN(i, 1, n) {
		scanf("%d", &p[i]);
		cnt[p[i]]++;
	}
	
	REPN(i, 1, n) {
		if (cnt[i] == n - 1) {
			ans[1] = i;
			REPN(j, 1, n) {
				if (j != ans[1] && j != p[ans[1]]) {
					ans[2] = j;
					break;
				}
			}
			int top = 3;
			REPN(j, 1, n) {
				if (j != ans[1] && j != ans[2]) {
					ans[top++] = j;
				}
			}
			REPN(j, 1, n) {
				printf("%d ", ans[j]);
			}
			putchar('\n');
			return;
		}
	}
	
	used[1] = 1;
	ans[1] = 1;
	cnt[p[1]]--;
	REPN(i, 2, n) {
		st.insert(i);
		stp.insert(mp(cnt[i], i));
	}
	top = 2;
	REPN(i, 2, n) {
		int v = stp.rbegin()->_2;
		if (cnt[v] == n - i) {
			add(v);
			continue;
		}
		
		v = *st.begin();
		for(; ; v = *st.upper_bound(v)) {
			if (v == p[ans[i - 1]]) {
				continue;
			}
			break;
		}
		add(v);
	}
	
	/*REPN(i, 1, n) {
		printf("%d ", ans[i]);
	}
	putchar('\n');*/
	
	FA(it, st) {
		ans[top++] = *it;
	}
	
	/*REPN(i, 1, n) {
		printf("%d ", ans[i]);
	}
	putchar('\n');*/
	
	REP(i, 0, 30) {
		int fl = 0;
		REPN(i, 1, n - 1) {
			if (ans[i + 1] == p[ans[i]]) {
				//printf("%d: %d %d\n", i, ans[i], ans[i + 1]);
				fl = 1;
				break;
			}
		}
		if (!fl) {
			REPN(i, 1, n) {
				printf("%d ", ans[i]);
			}
			putchar('\n');
			return;
		}
		/*REPN(i, 1, n) {
			printf("%d ", ans[i]);
		}
		putchar('\n');*/
		next_permutation(ans + 1, ans + n + 1);
	}
	printf("-1\n");
	return;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}
