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 <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

int N;
vector<int> p;
vector<set<int>> ip;

bool check(const vector<int> &res) {
    for (int i = 0; i + 1 < res.size(); ++i) {
        if (res[i+1] == p[res[i]]) return false;
    }
    return true;
}

void last(vector<int> &res, vector<int> &rem) {
    do {
        if (res.size() > 0 && rem[0] == p[res.back()]) continue;
        if (check(rem)) {
            for (int i = 0; i < res.size(); ++i) cout << res[i] + 1 << " ";
            for (int i = 0; i < rem.size(); ++i) cout << rem[i] + 1 << " ";
            cout << endl;
            return;
        }
    } while (next_permutation(rem.begin(), rem.end()));

    cout << -1 << endl;
    return;
}

const int NOKORI = 5;
void solve() {
    if (N <= NOKORI) {
        vector<int> res, rem(N);
        for (int i = 0; i < N; ++i) rem[i] = i;
        last(res, rem);
        return;
    }

    vector<int> res;
    set<int> rem;
    for (int i = 0; i < N; ++i) rem.insert(i);
    while (N - (int)res.size() > NOKORI) {
        int dame = -1;
        if (res.size() > 0) dame = p[res.back()];

        // とりあえず Greedy に
        int ne = -1;
        for (auto it : rem) {
            if (it == dame) continue;
            ne = it;
            break;
        }

        // ne を選んでしまうと詰むときは取り替える
        if (ip[p[ne]].size() + res.size() == N-1) {
            ne = p[ne];
        }

        // ne を選ぶ
        res.push_back(ne);
        rem.erase(ne);
        ip[p[ne]].erase(ne);
    }
    vector<int> vrem;
    for (int i = 0; i < N; ++i) if (rem.count(i)) vrem.push_back(i);
    last(res, vrem);
}

int main() {
    while (cin >> N) {
        p.resize(N);
        ip.assign(N, set<int>());
        for (int i = 0; i < N; ++i) {
            cin >> p[i];
            --p[i];
            ip[p[i]].insert(i);
        }
        solve();
    }
}
















