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>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N;
  while(cin >> N){
    vector<int> a(N); cin >> a;
    for(auto &x : a) x -= 1;

    if(N == 2){
      cout << -1 << endl;
    }else{

      vector<int> ans;

      vector<int> count(N);
      REP(i,N) count[a[i]] += 1;

      int cur = 0;

      REP(i,N){
        if(count[i] == N-1){
          cur = i;
          break;
        }
      }

      set<int> s;
      REP(i,N) s.insert(i);

      vector<set<int>> indeg(N);
      REP(i,N) indeg[count[i]].insert(i);

      while(not s.empty()){

        if(s.size() <= 5){
          vector<int> p;
          for(auto x : s) p.push_back(x);

          do{

            int c = cur;

            bool fail = false;

            for(auto x : p){
              if(a[c] == x){
                fail = true;
                break;
              }

              c = x;
            }


            if(not fail){
              for(auto &x : p) x += 1;
              ans.insert(ans.end(), ALL(p));

              break;
            }
            
          }while(next_permutation(ALL(p)));

          break;
        }

        indeg[count[cur]].erase(cur);
        
        s.erase(cur);
        ans.push_back(cur+1);

        indeg[count[a[cur]]].erase(a[cur]);
        
        count[a[cur]] -= 1;

        indeg[count[a[cur]]].insert(a[cur]);


        if(indeg[(int)s.size()-1].size()){
          cur = *(indeg[(int)s.size()-1].begin());
        }else{
          int k = 0;
          ITR(it, s){
            if(k >= 5) break;
            ++k;

            if(*it == a[cur]) continue;

            cur = *it;
            break;
          }
        }
      }
      
      
      join(cout, ALL(ans));
      
    }
  }

  

  return 0;
}
