#include <bits/stdc++.h>
using namespace std;
template <class T, class T2>
inline bool chkmax(T &x, const T2 &y) {
  return x < y ? x = y, 1 : 0;
}
template <class T, class T2>
inline bool chkmin(T &x, const T2 &y) {
  return x > y ? x = y, 1 : 0;
}
const long long mod = 1e9 + 7;
template <class T>
inline void fix(T &x) {
  if (x >= mod | x <= -mod) {
    x %= mod;
  }
  if (x < 0) {
    x += mod;
  }
}
const int MAX_N = 1e6 + 10;
long long arr[MAX_N];
long long cnt[MAX_N];
long long used[MAX_N];
vector<int> cycle;
long long ans[MAX_N];
void apply() {
  for (int i = 0; i < cycle.size(); i++) {
    if (i == 0) {
      ans[cycle[cycle.size() - 1]] = cycle[i];
    } else {
      ans[cycle[i - 1]] = cycle[i];
    }
  }
  cycle.resize(0);
}
void merge(int x, int y, int len) {
  for (int i = 0; i < len; i++) {
    cycle.push_back(x);
    cycle.push_back(y);
    x = arr[x];
    y = arr[y];
  }
  apply();
}
void fakeShift(int x, int len) {
  cycle.resize(len);
  for (int i = 0; i < len; i++) {
    cycle[(2 * i) % len] = x;
    x = arr[x];
  }
  apply();
}
signed main() {
  fill_n(cnt, MAX_N, -1);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i]--;
  }
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      int curr = arr[i], len = 1;
      used[i] = used[curr] = true;
      while (curr != i) {
        len++;
        curr = arr[curr];
        used[curr] = true;
      }
      if (len & 1) {
        fakeShift(i, len);
      } else {
        if (cnt[len] == -1) {
          cnt[len] = i;
        } else {
          merge(i, cnt[len], len);
          cnt[len] = -1;
        }
      }
    }
  }
  for (int i = 0; i < MAX_N; i++) {
    if (cnt[i] != -1) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] + 1 << " ";
  }
  return 0;
}
