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 <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        if (N == 2) {
            cout << -1 << endl;
            return;
        }

//        vector<vector<Int>> G(N); // ng edge
        vector<Int> a(N);
        vector<set<Int>> rG(N); // ng edge

        for (int i = 0; i < N; ++i) {
            cin >> a[i];
            a[i]--;
            rG[a[i]].insert(i);
        }

        Int V = N; // 残りの頂点数
        Int ng = -1; //使ってはいけない頂点
        set<Int> rest;
        for (int i = 0; i < N; ++i) rest.insert(i);
        map<Int, set<Int>> mp; //first : 入次数, second : 頂点数

        for (int i = 0; i < N; ++i) {
            mp[rG[i].size()].insert(i);
        }

        vector<Int> path;
        for (; V > 3; V--) {
            Int next = -1;
            if (mp.count(V - 1)) {
                next = *mp[V - 1].begin();
            } else {
                auto pt = rest.begin();
                if (*pt == ng) {
                    pt++;
                }
                next = *pt;
            }

            path.push_back(next);
            rest.erase(next);
            ng = a[next];

            //a[next]が格納されているあれを削除
            Int t = a[next];
            mp[rG[t].size()].erase(t);
            if (mp[rG[t].size()].size() == 0) {
                mp.erase(rG[t].size());
            }

            rG[t].erase(next);
            mp[rG[t].size()].insert(t);
        }

        //nextperm

        vector<Int> v;
        for (auto e : rest) {
            v.push_back(e);
        }

        do {
            bool flag = true;
            if (ng == v[0]) {
                flag = false;
            }
            for (int i = 0; i + 1 < v.size(); ++i) {
                if (a[v[i]] == v[i + 1]) {
                    flag = false;
                }
            }
            if (flag) {
                for (auto e : v) {
                    path.push_back(e);
                }
                break;
            }
        } while (next_permutation(all(v)));

        for (auto e : path) {
            cout << e + 1 << ' ';
        }
        cout << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}
