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
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  if (n == 2) {
    cout << "-1\n";
    return 0;
  }
  vector<int> a(n), cnt(n, 0);
  REP(i, n) {
    cin >> a[i]; --a[i];
    ++cnt[a[i]];
  }
  map<int, set<int> > mp;
  REP(i, n) mp[cnt[i]].emplace(i);
  vector<int> b;
  set<int> st;
  REP(i, n) st.emplace(i);
  REP(i, n - 8) {
    if (mp.rbegin()->first == n - 1 - i) {
      assert(mp.rbegin()->second.size() == 1);
      b.emplace_back(*mp.rbegin()->second.begin());
    } else if (i == 0 || a[b[i - 1]] != *st.begin()) {
      b.emplace_back(*st.begin());
    } else {
      b.emplace_back(*next(st.begin()));
    }
    st.erase(b[i]);
    mp[cnt[b[i]]].erase(b[i]);
    if (mp[cnt[b[i]]].empty()) mp.erase(cnt[b[i]]);
    int A = a[b[i]];
    mp[cnt[A]].erase(A);
    if (mp[cnt[A]].empty()) mp.erase(cnt[A]);
    --cnt[A];
    mp[cnt[A]].emplace(A);
  }
  vector<int> per;
  for (int e : st) per.emplace_back(e);
  int m = per.size();
  do {
    bool ok = (n <= 8 || a[b.back()] != per[0]);
    REP(i, m - 1) ok &= a[per[i]] != per[i + 1];
    if (ok) {
      for (int e : per) b.emplace_back(e);
      break;
    }
  } while (next_permutation(ALL(per)));
  REP(i, n) cout << b[i] + 1 << " \n"[i + 1 == n];
  return 0;
}
