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>

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

set<int> st;
vi ans;
vi sz;
bool ok = false;
int ng = -1;
void sch(int n, int k, vi &a) {
  if(n - k <= 5) {
    vi rem;
    for(auto &e: st) rem.push_back(e);
    REP(i, 120) {
      bool tmp = true;
      tmp &= ans.empty() || a[ans.back()] != rem[0];
      REP(j, SZ(rem)-1) {
        tmp &= a[rem[j]] != rem[j+1];
      }
      if(tmp) {
        ok = true;
        break;
      }
      next_permutation(ALL(rem));
    }
    if(ok) for(auto &e: rem) ans.push_back(e);
  } else {
    int mi = INF;
    for(auto &e: st) {
      if(e != ng) {
        mi = e;
        break;
      }
    }

    if(mi == INF) {
      return;
    }

    if(sz[a[mi]] == n - k - 1) {
      mi = a[mi];
    }

    ng = a[mi];
    sz[a[mi]]--;
    st.erase(mi);
    ans.push_back(mi);
    sch(n, k+1, a);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi a(n);
  sz.resize(n);
  REP(i, n) {
    cin >> a[i];
    a[i]--;
    sz[a[i]]++;
  }
  REP(i, n) st.insert(i);

  sch(n, 0, a);

  if(!ok) {
    cout << -1 << endl;
    return 0;
  }
  REP(i, n) {
    cout << ans[i]+1;
    cout << " ";
  }
  cout << endl;

}






















