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;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> a(N);
    for (int i=0;i<N;++i) cin >> a[i];
    if (N==2){cout << -1 << '\n'; return 0;}
    vector<int> deg(N,0),used(N,0),ans(N,-1);
    for (int i=0;i<N;++i) ++deg[--a[i]];
    set<pair<int,int>> s;
    priority_queue<int,vector<int>,greater<int>> skipped;
    for (int i=0;i<N;++i) s.emplace(-deg[i],i);
    for (int i=0,now=0;i<N-3;++i){
        auto p=*s.begin();
        if (-p.first==N-1-i){
            ans[i]=p.second;
        } else if (!i){
            ans[i]=0;
        } else {
            if (!skipped.empty()){
                int x=skipped.top(); skipped.pop();
                if (a[ans[i-1]]!=x) ans[i]=x;
                else if (!skipped.empty()){
                    ans[i]=skipped.top();
                    skipped.pop(); skipped.emplace(x);
                } else skipped.emplace(x);
            }
            if (ans[i]<0){
                while(used[now]) ++now;
                if (a[ans[i-1]]==now) skipped.emplace(now++);
                while(used[now]) ++now;
                ans[i]=now;
            }
        }
        used[ans[i]]=1;
        s.erase({-deg[ans[i]],ans[i]});
        int nxt=a[ans[i]];
        if (used[nxt]) continue;
        s.erase({-deg[nxt],nxt});
        --deg[nxt];
        s.emplace(-deg[nxt],nxt);
    }
    vector<int> unused,res(3,N);
    for (int i=0;i<N;++i) if (!used[i]) unused.emplace_back(i);
    vector<int> perm(3);
    iota(perm.begin(),perm.end(),0);
    do {
        vector<int> cnt(3);
        for (int i=0;i<3;++i) cnt[i]=unused[perm[i]];
        if (N>3&&a[ans[N-4]]==cnt[0]) continue;
        if (a[cnt[0]]==cnt[1]) continue;
        if (a[cnt[1]]==cnt[2]) continue;
        res=min(res,cnt);
    } while(next_permutation(perm.begin(),perm.end()));
    for (int i=0;i<3;++i) ans[N-3+i]=res[i];
    for (int i=0;i<N;++i) cout << ans[i]+1 << (i+1==N?'\n':' ');
}