#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> next(n);
  for (int x, i = 0; i < n; ++i) {
    scanf("%d", &x);
    --x;
    next[i] = x;
  }
  vector<vector<vector<int> > > seq(n + 1);
  vector<bool> vis(n);
  for (int i = 0; i < n; ++i) {
    if (vis[i]) continue;
    int u = i;
    vector<int> cur;
    do {
      vis[u] = true;
      cur.push_back(u);
      u = next[u];
    } while (!vis[u]);
    seq[cur.size()].push_back(cur);
  }
  vector<int> sol(n);
  for (int sz = 1; sz <= n; ++sz) {
    if (sz & 1) {
      for (auto &cur : seq[sz]) {
        vector<int> f(sz);
        for (int i = 0, it = 0; it != sz; ++it, i = (i + 2) % sz)
          f[i] = cur[it];
        for (int i = 0; i < sz; ++i) sol[f[i]] = f[(i + 1) % sz];
      }
    } else {
      if (seq[sz].size() & 1) {
        puts("-1");
        return 0;
      }
      while (!seq[sz].empty()) {
        auto a = seq[sz].back();
        seq[sz].pop_back();
        auto b = seq[sz].back();
        seq[sz].pop_back();
        for (int i = 0; i < sz; ++i) {
          sol[a[i]] = b[i];
          sol[b[i]] = a[(i + 1) % sz];
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) printf("%d ", sol[i] + 1);
  return 0;
}
