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>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e5+10;
int n,a[N],cnt[N];

set<int>s;
set<pa>S;
int b[N];
inline void print(){
	For(i,1,n) printf("%d ",b[i]);
	exit(0);
}
bool vis[N];
inline void dfs(int u,int ban){
	if (u==n+1) print();
	if (!S.empty()){
		auto tmp=*(--S.end());
		if (tmp.fi>=n-u&&u!=n){
			if (tmp.se==ban) return;
			int nxt=tmp.se,x=a[nxt];
			b[u]=nxt,s.erase(nxt);
			S.erase(mp(cnt[nxt],nxt));
			vis[nxt]=1;
			if (!vis[x]) S.erase(mp(cnt[x],x)),--cnt[x],S.insert(mp(cnt[x],x));
			dfs(u+1,a[nxt]);
			vis[nxt]=0,s.insert(nxt);
			S.insert(mp(cnt[nxt],nxt));
			if (!vis[x]) S.erase(mp(cnt[x],x)),++cnt[x],S.insert(mp(cnt[x],x));
		}
	}
	auto nxt=*s.begin();
	while (233){
		if (nxt==ban){
			auto it=s.upper_bound(nxt);
			if (it==s.end()) break;
			nxt=*it;
		}
		int x=a[nxt];
		b[u]=nxt,s.erase(nxt);
		S.erase(mp(cnt[nxt],nxt));
		vis[nxt]=1;
		if (!vis[x]) S.erase(mp(cnt[x],x)),--cnt[x],S.insert(mp(cnt[x],x));
		dfs(u+1,a[nxt]);
		vis[nxt]=0,s.insert(nxt);
		S.insert(mp(cnt[nxt],nxt));
		if (!vis[x]) S.erase(mp(cnt[x],x)),++cnt[x],S.insert(mp(cnt[x],x));
		auto it=s.upper_bound(nxt);
		if (it==s.end()) break;
		nxt=*it;
	}
}

int main(){
	n=read();
	if (n==2) return puts("-1"),0;
	For(i,1,n) a[i]=read(),cnt[a[i]]++;
	For(i,1,n) s.insert(i),S.insert(mp(cnt[i],i));
	dfs(1,0);
}