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 <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

void solve3(vector<LL>& ans, vector<LL>& a, vector<LL>& tri){
    for(LL i = 0; i < 3; ++i){
        for(LL j = 0; j < 3; ++j){
            for(LL k = 0; k < 3; ++k){
                if(i == j || j == k || k == i) continue;
                if(ans.size() > 0 && a[ans[ans.size()-1]] == tri[i]) continue;
                if(a[tri[i]] != tri[j] && a[tri[j]] != tri[k]){
                    ans.push_back(tri[i]);
                    ans.push_back(tri[j]);
                    ans.push_back(tri[k]);
                    return;
                }
            }
        }
    }
}


int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    vector<LL> indegree(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
        --a[i];
        indegree[a[i]] += 1;
    }
    if(n <= 2){
        cout << -1 << endl;
        return 0;
    }

    set<pair<LL,LL>> ordered;
    set<LL> rest;
    for(LL i = 0; i < n; ++i){
        rest.insert(i);
        ordered.insert(pair<LL,LL>(indegree[i], i));
    }
    vector<LL> used(n);
    vector<LL> ans;
    for(LL i = 0; i+3 < n; ++i){
        while(!ordered.empty()){
            LL val = ordered.rbegin()->first;
            LL key = ordered.rbegin()->second;
            if(used[key]){
                ordered.erase(--ordered.end());
                continue;
            }
            if(val != indegree[key]){
                ordered.erase(--ordered.end());
                ordered.insert(pair<LL,LL>(indegree[key], key));
                continue;
            }
            break;
        }
        if(!ordered.empty()){
            LL val = ordered.rbegin()->first;
            LL key = ordered.rbegin()->second;
            if(val == n-1-i){
                ans.push_back(key);
                used[key] = 1;
                indegree[a[key]] -= 1;
                rest.erase(key);
                continue;
            }
        }
        for(LL cur: rest){
            if(i > 0 && a[ans[ans.size()-1]] == cur){
                continue;
            }
            ans.push_back(cur);
            used[cur] = 1;
            indegree[a[cur]] -= 1;
            rest.erase(cur);
            break;
        }
    }
    assert(rest.size() == 3);
    vector<LL> tri(rest.begin(), rest.end());
    solve3(ans, a, tri);
    for(LL i = 0; i < n; ++i){
        cout << ans[i]+1 << ((i+1==n)?"\n":" ");
    }
    return 0;
}

