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
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n;
int a[MAX_N];
set<int> in[MAX_N];
map<int, set<int>, greater<int>> by_size;
vi ans;

void insert(int v) {
    by_size[in[v].size()].insert(v);
}

void erase(int v) {
    by_size[in[v].size()].erase(v);
    if (by_size[in[v].size()].empty()) {
        by_size.erase(in[v].size());
    }
}

int find_min(set<int>& s) {
    assert(!s.empty());

    vi l;
    if (by_size.begin()->fst >= s.size() - 1) {
        l.push_back(*(by_size.begin()->snd.begin()));
    } else {
        int c = 0;
        for (auto it = s.begin(); it != s.end() && c < 3; it++, c++) {
            l.push_back(*it);
        }
    }

    for (int v : l) {
        bool ok = ans.empty() || a[ans.back()] != v;

        if (s.size() == 3) {
            int x = -1, y = -1;
            for (int u : s) {
                if (u == v) continue;
                if (x >= 0)
                    y = u;
                else
                    x = u;
            }

            ok &= a[x] != y || a[y] != x;
        }

        if (ok) {
            return v;
        }
    }
    return -1;
}

bool rec(set<int>& s) {
    if (s.empty()) return true;

    int u = find_min(s);
    //cout << "u=" << u << endl;
    if (u < 0)
        return false;
    else {
        s.erase(u);
        erase(u);
        if (contains(s, a[u])) {
            erase(a[u]);
            in[a[u]].erase(u);
            insert(a[u]);
        }
        ans.push_back(u);

        return rec(s);
    }
}

int main() {
    fastio();

    cin >> n;

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

    forn(i, n) {
        cin >> a[i];
        a[i]--;
        in[a[i]].insert(i);
    }

    set<int> s;
    forn(i, n) {
        s.insert(i);
        insert(i);
    }

    if (!rec(s)) {
        ans.clear();
        ans.push_back(-2);
    }

    for (int v : ans) {
        cout << v + 1 << ' ';
    }
    cout << endl;

    return 0;
}