#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1000005;
int a[NMAX], sol[NMAX];
bool viz[NMAX];
vector<vector<int>> odd, even;
bool cmp(const vector<int> &a, const vector<int> &b) {
  return a.size() < b.size();
}
int main() {
  cin.sync_with_stdio(false);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    if (!viz[i]) {
      vector<int> cycle;
      for (int j = i; !viz[j]; j = a[j]) {
        cycle.push_back(j);
        viz[j] = 1;
      }
      if (cycle.size() & 1)
        odd.push_back(cycle);
      else
        even.push_back(cycle);
    }
  if (even.size() & 1) return 0 * printf("-1");
  sort(even.begin(), even.end(), cmp);
  for (int i = 0; i < even.size(); i += 2) {
    if (even[i].size() != even[i + 1].size()) return 0 * printf("-1");
    even[i].push_back(even[i][0]);
    for (int j = 0; j < even[i + 1].size(); j++) {
      sol[even[i][j]] = even[i + 1][j];
      sol[even[i + 1][j]] = even[i][j + 1];
    }
  }
  for (int i = 0; i < odd.size(); i++) {
    odd[i].push_back(odd[i][0]);
    for (int j = 0, k = odd[i].size() / 2; k < odd[i].size(); j++, k++) {
      sol[odd[i][j]] = odd[i][k];
      sol[odd[i][k]] = odd[i][j + 1];
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", sol[i]);
  return 0;
}
