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 pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int a[125252];
set<int> indeg[125252];
int ans[125252];

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",a+i),a[i]--;
    REP(i,n)indeg[a[i]].insert(i);
    set<pii> S;
    REP(i,n)S.insert(pii(indeg[i].size(), i));
    set<int> rest;
    REP(i,n)rest.insert(i);
    int ban = -1;

    int it = 0;
    REP(i,n){
        if(rest.size() < 8){
            it = i;
            break;
        }
        int cand = -1;
        if(S.rbegin()->first == n-i-1){
            // must choose
            cand = S.rbegin()->second;
        }else if(*rest.begin() != ban){
            // can choose
            cand = *rest.begin();
        }else if(rest.size()>1){
            // next
            auto it = rest.begin();
            it++;
            cand = *it;
        }else{
            puts("-1"); return 0;
        }
        ans[i] = cand;
        ban = a[cand];
        rest.erase(cand);
        S.erase(pii(indeg[cand].size(), cand));
        if(rest.count(ban)){
            S.erase(pii(indeg[ban].size(), ban));
            indeg[ban].erase(cand);
            S.insert(pii(indeg[ban].size(), ban));
        }
    }
    vi v;
    for(int x : rest){
        v.push_back(x);
    }

    do{
        FOR(i,it,n)ans[i] = v[i-it];
        bool ook = true;
        REP(i,n-1)if(ans[i+1] == a[ans[i]]){
            ook = false;
        }
        if(ook){
            break;
        }
    }while(next_permutation(ALL(v)));

    bool ook = true;
    REP(i,n-1)if(ans[i+1] == a[ans[i]]){
        ook = false;
    }
    if(!ook){
        puts("-1"); return 0;
    }
    REP(i,n)printf("%d%c",ans[i]+1," \n"[i==n-1]);
    return 0;
}
