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;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

void solve(ll N,vector<ll> &ans,vector<ll> &A){
  for(int i=0;i<N;i++){ans[i]=i;}
  do{
    bool jd=true;
    for(int i=0;i+1<N;i++){
      jd&=A[ans[i]]!=ans[i+1];
    }
    if(jd){break;}
  }while(next_permutation(ans.begin(),ans.end()));
}

void output(ll N,vector<ll> ans,vector<ll> A){
  bool jd=true;
  for(int i=0;i+1<N;i++){
    jd&=A[ans[i]]!=ans[i+1];
  }
  assert(jd);
  for(auto &I:ans){I++;}
  cout<<ans<<endl;
  sort(ans.begin(),ans.end());
  //for(int i=0;i<N;i++){assert(ans[i]==i+1);}
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<ll> A(N),ans(N,-1),cnt(N,0);
  set<ll> S;
  priority_queue<pll> Q;
  cin>>A;
  for(auto &I:A){I--; cnt[I]++; Q.push({cnt[I],I});}
  for(int i=0;i<N;i++){S.insert(i);}
  auto answer=[&](int i,int a){ans[i]=a; cnt[A[a]]--; S.erase(a);};
  if(N<=8){
    solve(N,ans,A);
    bool jd=true;
    for(int i=0;i+1<N;i++){
      jd&=A[ans[i]]!=ans[i+1];
    }
    for(auto &I:ans){I++;}
    if(jd){cout<<ans<<endl;}
    else{cout<<-1<<endl;}
    return 0;
  }

  
  for(int i=0;i+5<N;i++){
    while(!Q.empty()){
      pll u=Q.top();
      if(cnt[u.S]!=u.F || S.count(u.S)==0){Q.pop(); continue;}
      break;
    }
    if(!Q.empty() && cnt[Q.top().S]>=N-i-1){
      assert(A[Q.top().S]!=Q.top().S);
      answer(i,Q.top().S);
      for(int j=i+1;j<N;j++){
        ll k=*S.lower_bound(-1LL);
        if(j==0 || k!=A[ans[j-1]]){
          answer(j,k);
        }
        else{
          S.erase(k);
          ll k2=*S.lower_bound(-1LL);
          answer(j,k2);
          S.insert(k);
        }
      }
      for(auto &I:ans){I++;}
      cout<<ans<<endl;
      return 0;
    }
    ll k=*S.lower_bound(-1LL);
    if(i==0 || k!=A[ans[i-1]]){
      answer(i,k);
    }
    else{
      S.erase(k);
      ll k2=*S.lower_bound(-1LL);
      answer(i,k2);
      S.insert(k);
    }
  }
  
  vector<ll> rem;
  for(auto &I:S){rem.push_back(I);}
  assert(rem.size()==5);
  ll C=N-5;
  do{
    for(int i=0;i<5;i++){
      ans[C+i]=rem[i];
    }
    bool jd=true;
    for(int i=max(0LL,N-10);i+1<N;i++){
      jd&=A[ans[i]]!=ans[i+1];
    }
    if(jd){break;}
  }while(next_permutation(rem.begin(),rem.end()));
  bool jd=true;
  for(int i=0;i+1<N;i++){
    jd&=A[ans[i]]!=ans[i+1];
  }
  assert(jd);
  for(auto &I:ans){I++;}
  cout<<ans<<endl;

  return 0;
}
