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 int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int N;
int A[111111];

bool check(const vint &v){
    rep(i,N-1){
        if(A[v[i]]==v[i+1])return false;
    }
    return true;
}

int deg[111111];
signed main(){
    cin>>N;
    rep(i,N)cin>>A[i],A[i]--;

    if(N==2){
        cout<<-1<<endl;
        return 0;
    }

    set<int>s;
    rep(i,N)s.insert(i);

    rep(i,N)deg[A[i]]++;

    vint vs;
    int pre=-1;
    while(s.size()>3){
        int v=*s.begin();
        s.erase(v);

        if(pre!=-1&&A[pre]==v){
            int vv=*s.begin();
            s.erase(vv);
            s.insert(v);
            v=vv;
        }

        if(s.find(A[v])!=s.end()&&deg[A[v]]==s.size()){
            int vv=A[v];
            s.insert(v);
            s.erase(vv);
            v=vv;
        }
        deg[A[v]]--;

        vs.pb(v);
        pre=v;
    }

    vint rm;
    for(auto v:s)rm.pb(v);

    const int INF=1001001001;
    vint ans(N,INF);

    do{
        vint tmp=vs;
        tmp.insert(tmp.end(),all(rm));
        if(check(tmp))chmin(ans,tmp);
    }while(next_permutation(all(rm)));


    rep(i,ans.size()){
        if(i)cout<<" ";
        cout<<ans[i]+1;
    }
    cout<<endl;
    return 0;
}