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 <bits/stdc++.h>

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<int> a;
  Solver(LL n) : n(n), a(n){};

  void solve() {
    vector<int> cnt(n), ans;
    vector<vector<int>> memo(n);
    set<int> rem;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      a[i]--;
      cnt[a[i]]++;
      rem.insert(i);
    }
    for (int i = 0; i < n; ++i) {
      memo[cnt[i]].push_back(i);
    }
    for (int i = 0; i < n; ++i) {
      int nxt = -1;
      for (auto p : memo[n - i - 1]) {
        if (cnt[p] == n - i - 1) {
          //assert(nxt == -1);
          nxt = p;
        } else if (cnt[p] > 0) {
          memo[cnt[p]].push_back(p);
        }
      }
      if (nxt != -1) {
        ans.push_back(nxt);
        cnt[a[nxt]]--;
        cnt[nxt] = -1;
        rem.erase(nxt);
      } else {
        if (i == n - 3) {
          set<int> rem2(rem);
          if (ans.size() > 0) {
            rem2.erase(a[ans.back()]);
          }
          DBG(rem, rem2)
          vector<int> tmp;
          for (auto x : rem) {
            tmp.push_back(x);
          }
          sort(tmp.begin(), tmp.end());
          for (int i = 0; i < 3; ++i) {
            vector<int> pr;
            for (int j = 0; j < 3; ++j) {
              if (j == i) continue;
              pr.push_back(tmp[j]);
            }
            if (a[pr[0]] == pr[1] && a[pr[1]] == pr[0]) {
              if (rem2.count(tmp[i])) rem2.erase(tmp[i]);
            }
          }
          int nxt = *rem2.begin();
          ans.push_back(nxt);
          cnt[a[nxt]]--;
          cnt[nxt] = -1;
          rem.erase(nxt);
          continue;
        }
        auto it = rem.begin();
        if (ans.size() > 0 && *it == a[ans.back()])
          it++;
        if (it == rem.end()) {
          cout << -1 << endl;
          return;
        }
        int tmp = *it;
        ans.push_back(tmp);
        cnt[a[tmp]]--;
        cnt[tmp] = -1;
        rem.erase(tmp);
      }
    }

    for (int i = 0; i < n; ++i) {
      cout << ans[i] + 1 << ' ';
    }
    cout << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}
