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;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
 
const int N=2e5+5;
int a[N],z=0,s[N];
int cnt[N],u[N];
set<int> cs[N];
int n;
int le[N],ri[N];
void del(int v){
    assert(!u[v]);
    u[v]=1;
    le[ri[v]]=le[v];
    ri[le[v]]=ri[v];
}
void ret(int v){
    assert(u[v]);
    u[v]=0;
    le[ri[v]]=v;
    ri[le[v]]=v;
}
void f(int v){
    // dbg("put",v);
    assert(a[s[z]]!=v);
    cs[cnt[v]].erase(v);
    if(!u[a[v]]){
        cs[cnt[a[v]]].erase(a[v]);
        --cnt[a[v]];
        cs[cnt[a[v]]].insert(a[v]);
    }
    del(v);
    s[++z]=v;
}
void b(){
    // dbg("del");
    if(z){
        int v=s[z--];
        // dbg("del",v);
        cs[cnt[v]].insert(v);
        if(!u[a[v]]){
            cs[cnt[a[v]]].erase(a[v]);
            ++cnt[a[v]];
            cs[cnt[a[v]]].insert(a[v]);
        }
        ret(v);
    }
}
void rec(){
    int r=n-z;
    dbg(z,r);
    if(!r){
        for(int i=1;i<=n;++i)
            cout<<s[i]<<' ';
        cout<<'\n';
        exit(0);
    }
    // for(int i=0;i<=n;++i){
    //     if(sz(cs[i])){
    //         cerr<<"cnt "<<i<<": ";for(int j:cs[i])cerr<<j<<' ';cerr<<'\n';
    //     }
    // }
    if(sz(cs[r-1])>1)b();
    else if(sz(cs[r-1])==1){
        int v=*cs[r-1].begin();
        f(v);
        rec();
    }else{
        int i=ri[0];
        while(i!=n+1){
            if(a[s[z]]!=i){
                f(i);
                rec();
            }
            i=ri[i];
        }
    }
}
int32_t main(){
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        cnt[a[i]]++;
    }
    ri[0]=1;le[n+1]=n;
    for(int i=1;i<=n;++i){
        cs[cnt[i]].insert(i);
        le[i]=i-1;
        ri[i]=i+1;
    }
    rec();
    cout<<"-1\n";
    return 0;
}