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 <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define int long long
const int N = 1e6;

int n;
int a[N];
int cnt[N];
int used[N];
set<pair<int, int> > mm, mm2;
vector<int> ans;

int get2(int x)
{
    auto it = mm2.lower_bound({x, -1});
    return (*it).second;
}

int ch(int lst, int x, int t)
{
    if (a[lst] == x)
    {
        return 0;
    }
    int cn = get2(x);
    mm.erase({cn, x});
    mm2.erase({x, cn});
    if (t == 0)
    {
        int nxt = a[x];
        if (!used[nxt])
        {
            int cnnxt = get2(nxt);
            mm.erase({cnnxt, nxt});
            mm.insert({cnnxt - 1, nxt});
            mm2.erase({nxt, cnnxt});
            mm2.insert({nxt, cnnxt - 1});
        }
        return 1;
    }
    auto it = mm.end();
    it--;
    if ((*it).first == mm.size())
    {
        mm.insert({cn, x});
        mm2.insert({x, cn});
        return 0;
    }
    mm.insert({cn, x});
    mm2.insert({x, cn});
    return 1;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for (int i = 1; i <= n; i++)
    {
        mm.insert({cnt[i], i});
        mm2.insert({i, cnt[i]});
    }
    for (int i = n; i >= 5; i--)
    {
        int lst = 0, t = n + 1;
        if (ans.size()) lst = ans.back();
        auto it1 = mm.end();
        it1--;
        auto it2 = mm.end();
        it2--;
        it2--;
        auto it3 = mm2.begin();
        auto it4 = mm2.begin();
        it4++;
        pair<int, int> i1 = *it1;
        pair<int, int> i2 = *it2;
        pair<int, int> i3 = *it3;
        pair<int, int> i4 = *it4;
        int w = 0;
        if (ch(lst, i1.second, 1)) t = min(t, i1.second), w = (i1.first + 1 == i);
        if (!w && ch(lst, i2.second, 1)) t = min(t, i2.second), w = (i2.first + 1 == i);
        if (!w && ch(lst, i3.first, 1)) t = min(t, i3.first);
        if (!w && ch(lst, i4.first, 1)) t = min(t, i4.first);
        if (t == n + 1) cout << -1, exit(0);
        ch(lst, t, 0);
        used[t] = 1;
        ans.push_back(t);
    }
    vector<int> p;
    int lst = 0;
    if (ans.size()) lst = ans.back();
    for (int i = 1; i <= n; i++) if (used[i] == 0) p.push_back(i);
    while (1)
    {
        int t = 1;
        if (a[lst] == p[0]) t = 0;
        for (int i = 1; i < p.size(); i++)
            if (a[p[i - 1]] == p[i]) t = 0;
        if (t)
        {
            for (int i = 0; i < p.size(); i++)
                ans.push_back(p[i]);
            break;
        }
        if (!next_permutation(all(p)))
        {
            cout << -1, exit(0);
        }
    }
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
