#include <bits/stdc++.h>
using namespace std;
namespace INIT {
char buf[1 << 15], *fs, *ft;
inline char getc() {
  return (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), fs == ft))
             ? 0
             : *fs++;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getc();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getc();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getc();
  }
  return x * f;
}
}  // namespace INIT
using namespace INIT;
int n, p[1000010], vis[1000010], ans[1000010];
vector<int> a[1000010], b[1000010];
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) p[i] = read();
  for (int i = 1; i <= n; ++i) {
    int num = 0;
    for (int j = i; !vis[j]; j = p[j]) vis[j] = 1, ++num, a[i].push_back(j);
    b[num].push_back(i);
  }
  for (int i = 1; i <= n; ++i)
    if (i % 2 == 0 && (b[i].size() & 1)) {
      puts("-1");
      return 0;
    }
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i <= (int)b[1].size() - 1; ++i) ans[b[1][i]] = b[1][i];
  for (int i = 2; i <= n; ++i)
    for (int j = 0; j <= (int)b[i].size() - 1; ++j) {
      if (i & 1) {
        int x = a[b[i][j]][0], y = a[b[i][j]][i / 2 + 1];
        while (!vis[x]) {
          vis[x] = vis[y] = 1;
          ans[x] = y;
          x = p[x];
          ans[y] = x;
          y = p[y];
        }
      } else {
        int x = a[b[i][j]][0], y = a[b[i][j + 1]][0];
        while (!vis[x] && !vis[y]) {
          vis[x] = vis[y] = 1;
          ans[x] = y;
          x = p[x];
          ans[y] = x;
          y = p[y];
        }
        j++;
      }
    }
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  return 0;
}
