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;

template<class Monoid> struct SegmentTree {
    using Function = function< Monoid(Monoid, Monoid) >;

    int N; vector<Monoid> segment;
    const Function func;
    const Monoid id;

    SegmentTree(int n, const Function func, const Monoid id) : func(func), id(id) {
        N = 1;
        while (N < n) N <<= 1;
        segment.assign(2 * N, id);
    }

    void set(int num, Monoid x) {
        segment[N + num] = x;
    }
    void build() {
        for (int k = N - 1; k > 0; k--) {
            segment[k] = func(segment[2*k], segment[2*k+1]);
        }
    }
    void update(int k, Monoid x) {
        k = k + N; segment[k] = x;
        while(k >>= 1) {
            segment[k] = func(segment[2*k], segment[2*k+1]);
        }
    }

    // query:[a, b)
    Monoid query(int a, int b) {
        Monoid L = id; Monoid R = id; a += N; b += N;
        for (; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = func(L, segment[a++]);
            if (b & 1) R = func(segment[--b], R);
        }
        return func(L, R);
    }
    // 0-based numbering;
    Monoid operator[](const int k) const {
        return segment[N+k];
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n+1), p(n+1, 0), u(n+1, 0);
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (n == 2) {
        if (a[1] == 2 && a[2] == 1) cout << -1 << "\n";
        else {
            if (a[1] == 2) cout << 2 << " " << 1 << "\n";
            else cout << 1 << " " << 2 << "\n";
        }
        return 0;
    }
    for (int i = 1; i <= n; i++) if (i != a[i]) p[a[i]]++;
    using dat = pair<int, int>;
    SegmentTree<dat> s(n+1, [](dat a, dat b){return max(a, b);}, {-1, -1e9});
    for (int i = 1; i <= n; i++) {
        s.set(i, {p[i], -i});
    }
    s.build();
    vector<int> v;
    int curr = 1;
    for (int i = 0; i < n-3; i++) {
        while (u[curr]) curr++;
        auto maxi = s.query(0, n+1);
        //cout << maxi.first << " " << maxi.second << "\n";
        int x = curr;
        if (i && a[v[i-1]] == x) {
            x++;
            while (u[x]) x++;
        }
        if (maxi.first >= (n-i-1)) x = -maxi.second;
        v.emplace_back(x);
        u[x] = true;
        auto y = a[x];
        auto z = s[y];
        s.update(x, {-1, -1e9});
        if (!u[y]) s.update(y, {z.first-1, z.second});        
    }
    vector<int> w;
    for (int i = 0; i < 3; i++) {
        auto maxi = s.query(0, n+1);
        w.emplace_back(-maxi.second);
        s.update(-maxi.second, {-1, -1e9});
    }
    sort(w.begin(), w.end());
    do {
        if (!v.empty() && a[v.back()] == w[0]) continue;
        bool ok = true;
        for (int i = 0; i < 2; i++) {
            if (a[w[i]] == w[i+1]) ok = false; 
        }
        if (ok) break; 
    } while (next_permutation(w.begin(), w.end()));
    for (auto &x: w) v.emplace_back(x);
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << v[i];
    }
    cout << "\n";
    return 0;
}