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 <set>
#include <vector>

using namespace std;

const int MAX_N = 1e5 + 5;

int forb [MAX_N];
int fc [MAX_N];
set<int> alive;
set<pair<int, int>> forb_cnts;

void del (int u) {
  alive.erase(u);
  forb_cnts.erase(make_pair(fc[forb[u]], forb[u]));
  fc[forb[u]]--;
  if (fc[forb[u]] > 0) {
    forb_cnts.insert(make_pair(fc[forb[u]], forb[u]));
  }
}

int cur_forb;
int special () {
  if ((int) alive.size() == 3) {
    int u = *alive.begin();
    int v = *next(alive.begin());
    int w = *alive.rbegin();

    if (forb[u] == v && forb[v] == u && forb[w] != u && forb[w] != v) {
      return min(u, v) == cur_forb ? max(u, v) : min(u, v);
    }
    swap(u, w);
    if (forb[u] == v && forb[v] == u && forb[w] != u && forb[w] != v) {
      return min(u, v) == cur_forb ? max(u, v) : min(u, v);
    }
    swap(u, w);
    swap(v, w);
    if (forb[u] == v && forb[v] == u && forb[w] != u && forb[w] != v) {
      return min(u, v) == cur_forb ? max(u, v) : min(u, v);
    }
  }
  
  if ((int) forb_cnts.size() == 2) {
    pair<int, int> fst = *forb_cnts.begin();
    pair<int, int> snd = *forb_cnts.rbegin();

    swap(fst, snd);

    if (snd.first == 1) {
      if (alive.count(fst.second)) return fst.second;
      else if (fst.first == 1 && alive.count(snd.second)) return snd.second;
    }
  }
  return 0;
}

int main () {
  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> forb[i];
    fc[forb[i]]++;
  }

  if (n == 2) {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 1; i <= n; i++) {
    if (fc[i] > 0) {
      forb_cnts.insert(make_pair(fc[i], i));
    }
  }

  for (int i = 1; i <= n; i++) {
    alive.insert(i);
  }

  vector<int> ans;

  for (int i = 1; i <= n; i++) {
    auto it = alive.begin();
    int to_del = special();
    if (to_del != 0 && to_del == cur_forb) {
      cerr << " ===== ERROR 2 ===== " << endl;
      exit(0);
    }
    if (to_del == 0) {
      while (*it == cur_forb) {
        it++;
        if (it == alive.end()) {
          cerr << " ====== ERROR ======= " << endl;
          exit(0);
        }
      }
      to_del = *it;
    }
    cur_forb = forb[to_del];
    cout << to_del << " ";
    del(to_del);
  }
  cout << endl;
}
