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 <functional>
#include <iostream>
#include <vector>
using namespace std;

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }

    void build() {
        for(int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while(k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = f(L, seg[a++]);
            if(b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
};

int main()
{
    int n;
    cin >> n;
    if(n == 2){
        cout << -1 << endl;
        return 0;
    }
    int a[100002];
    int l[100002]{0};
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
        l[a[i]]++;
    }
    SegmentTree<int> seg(n, [](int a, int b){return max(a, b);}, 0);
    for(int i = 0; i < n; i++) seg.set(i, l[i]);
    seg.build();
    int b[100002];
    bool used[100002]{0};
    int k = 0;
    for(int i = 0; i < n; i++){
        if(used[i]) continue;
        if(k == n - 1){
            b[k] = i;
            break;
        }
        if(seg.query(0, n) == n - k - 1){
            for(int j = 0; j < n; j++){
                if(seg[j] == n - k - 1){
                    b[k] = j;
                    k++;
                    used[j] = true;
                    seg.update(j, 0);
                    seg.update(a[j], seg[a[j]] - 1);
                    break;
                }
            }
            i--;
            continue;
        }
        if(k == n - 3){
            bool g = false;
            for(int j = 0; j < n; j++){
                if(!used[j] && !used[a[j]] && a[a[j]] == j){
                    if(a[b[k - 1]] != j){
                        g = true;
                        b[k] = j;
                        used[j] = true;
                        seg.update(j, 0);
                        seg.update(a[j], seg[a[j]] - 1);
                        i--;
                        break;
                    }
                }
            }
            if(g){
                k++;
                continue;
            }
        }
        if(k == 0){
            b[k] = 0;
            used[0] = true;
            seg.update(0, 0);
            seg.update(a[0], seg[a[0]] - 1);
        }
        else if(a[b[k - 1]] == i){
            for(int j = i + 1; j < n; j++) if(!used[j]){
                b[k] = j;
                used[j] = true;
                seg.update(j, 0);
                seg.update(a[j], seg[a[j]] - 1);
                i--;
                break;
            }
        }
        else{
            b[k] = i;
            used[i] = true;
            seg.update(i, 0);
            seg.update(a[i], seg[a[i]] - 1);
        }
        k++;
    }
    for(int i = 0; i < n; i++) cout << b[i] + 1 << " ";
    cout << endl;
}