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
// / #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <stack>
#include <sstream>
#include <regex>
 
#define prev asasddlsa
#define rank aljds
 
using namespace std;
 
typedef long long ll;
typedef long double dbl;

// mt19937 mrand(random_device{} ());
// int rnd(int x = INT_MAX) {
//     return mrand() % x;
// }

template<typename T>
void print(const vector<T>& s){
    for (auto x : s)
        cout << x + 1 << ' ';
    // cout << endl;
}
 
template<class T>
void print(const T* s, int n){
    for (int i = 0; i < n; i++){
        cout << s[i] << ' ';
    }
    cout << endl;
}
 
template<class T>
void print(vector<vector<T>> s){
    for (int i = 0; i < s.size(); i++)
        print(s[i]);
}

int main(){
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> s(n);
    set<int> unused;
    vector<int> deg(n);
    for (int i = 0; i < n; i++){
        cin >> s[i];
        s[i]--;
        deg[s[i]]++;
        unused.insert(i);
    }
    vector<int> order;
    while (unused.size() > 8){
        // bool ok = false;
        for (int x : unused){
            if (order.size() == 0 || s[order.back()] != x){
                if (unused.count(s[x]) && deg[s[x]] + 1 == unused.size()){
                    order.push_back(s[x]);
                    unused.erase(s[x]);
                    deg[s[s[x]]]--;
                } else {
                    order.push_back(x);
                    unused.erase(x);
                    deg[s[x]]--;
                }
                break;
            }
        }
    }
    vector<int> p;
    for (int x : unused)
        p.push_back(x);
    int t = order.size() ? order.back() : -1;
    do {
        if (t != -1 && s[t] == p[0])
            continue;
        bool ok = true;
        for (int i = 0; i + 1 < p.size(); i++){
            if (s[p[i]] == p[i + 1]){
                ok = false;
                break;
            }
        }
        if (ok){
            print(order);
            print(p);
            cout << endl;
            return 0;
        }
    } while (next_permutation(p.begin(), p.end()));
    cout << -1 << endl;
    return 0;
}
