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;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int N; cin >> N;
    vint A(N + 1);

    vector<set<int>> dat(N);
    set<int> rem;
    vint cnt(N+1, 0); 
    for (int i = 1; i <= N; i++) {
        int &v = A[i];
        dat[0].insert(i);
        rem.insert(i);

        cin >> v;
        cnt[v]++;
        dat[cnt[v] - 1].erase(v);
        dat[cnt[v]].insert(v);
    }
    if (N == 2) { cout << -1 << endl; return (0); }
    
    vint ans(N);
    for (int i = 0; i < N - 3; i++) {
        if (dat[N - i - 1].size() > 0) {
            int node = *begin(dat[N - i - 1]);
            rem.erase(node);
            ans[i] = node;
            continue;
        }
        for (auto v : rem) {
            if (i == 0 || A[ans[i - 1]] != v) {
                ans[i] = v;
                dat[cnt[v]].erase(v);
                dat[cnt[A[v]]].erase(A[v]);
                cnt[A[v]]--;
                dat[cnt[A[v]]].insert(A[v]);
                rem.erase(v);
                break;
            }
        }
    }
    
    vint vv;
    vv.push_back(*begin(rem)); rem.erase(vv.back());
    vv.push_back(*begin(rem)); rem.erase(vv.back());
    vv.push_back(*begin(rem)); rem.erase(vv.back());
    
    do {
        if ((N == 3 || A[ans[N - 4]] != vv[0]) && A[vv[0]] != vv[1] && A[vv[1]] != vv[2]) {
            ans[N - 3] = vv[0], ans[N - 2] = vv[1], ans[N - 1] = vv[2];
            break;
        }
    } while (next_permutation(begin(vv), end(vv)));
     
    cout << ans[0];
    for (int i = 1; i < N; i++) cout << " " << ans[i];
    cout << endl;


    return (0);
}