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 <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */
int N;
vector<int> p;
vector<set<int>> ip;

// ip[x] := x のことが嫌いな人の集合
// x を右隣に置きたくない人の集合

bool check(const vector<int> &res) {
  for(int i = 0; i + 1 < res.size(); i++) {
    if(res[i + 1] == p[res[i]]) return false;
  }
  return true;
}

const int NOKORI = 5;

// res は確定，rem を全探索
void last(vector<int> &res, vector<int> &rem) {
  do {
    if(check(rem)) {
      for(int i = 0; i < res.size(); i++) cout << res[i] + 1 << " ";
      for(int i = 0; i < rem.size(); i++) cout << rem[i] + 1 << " ";
      cout << endl;
      return;
    }
  }while(next_permutation(ALL(rem)));
  cout << -1 << endl;
  return;
}


void solve() {
  if(N <= NOKORI) {
    vector<int> res, rem(N);
    for(int i = 0; i < N; i++) rem[i] = i;
    last(res, rem);
    return;
  }

  vector<int> res;
  set<int> rem;
  for(int i = 0; i < N; i++) rem.insert(i);
  while(N - (int)res.size() > NOKORI) {
    int dame = -1;
    if(res.size() > 0) dame = p[res.back()];
    

    // とりあえず貪欲に
    int ne = -1;
    for(auto it : rem) {
      if(it == dame) continue;
      ne = it;
      break;
    }
    
    // ne を選んでしまうと詰むときは取り替える
    if(ip[p[ne]].size() + res.size() == N - 1) {
      ne = p[ne];
    }

    // ne を選ぶ
    // drken さん，ここら辺が綺麗すぎる
    res.push_back(ne);
    rem.erase(ne);
    ip[p[ne]].erase(ne);
  }
  
  vector<int> vrem;
  for(int i = 0; i < N; i++) if(rem.count(i)) vrem.push_back(i);
  last(res, vrem);
}

int main() {
  cin >> N;
  p.resize(N);
  ip.assign(N, set<int>());
  for(int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
    ip[p[i]].insert(i);
  }

  solve();
  return 0;
}
