#include <bits/stdc++.h>
using namespace std;
bool v[1100001];
int i, j, k, n, m, a[1100001], b[1100001], q[1100001], h[1100001], num,
    w[1100001];
void work1(int x) {
  int i, m;
  for (m = 1, q[1] = a[x], i = a[a[x]]; i != q[1]; i = a[i]) q[++m] = i;
  for (i = 1, w[m] = q[m]; i <= m / 2; i++)
    w[2 * i] = q[i], w[2 * i - 1] = q[i + m / 2];
  for (i = 1, b[w[m]] = w[1]; i < m; i++) b[w[i]] = w[i + 1];
}
void work2(int x, int y) {
  int i, j, m;
  for (m = 2, q[1] = a[x], q[2] = a[y], i = a[a[x]], j = a[a[y]]; i != q[1];
       i = a[i], j = a[j]) {
    q[++m] = i;
    q[++m] = j;
  }
  for (i = 1, b[q[m]] = q[1]; i < m; i++) b[q[i]] = q[i + 1];
}
int main() {
  scanf("%d", &n);
  memset(v, 0, sizeof(v));
  memset(h, 0, sizeof(h));
  num = 0;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) {
    if (v[i]) continue;
    for (k = 0, j = a[i]; !v[j]; j = a[j]) v[j] = 1, k++;
    if (k & 1)
      num += k, work1(i);
    else {
      if (!h[k]) {
        h[k] = i;
      } else {
        num += 2 * k;
        work2(h[k], i);
        h[k] = 0;
      }
    }
  }
  if (num < n)
    puts("-1");
  else {
    for (i = 1; i <= n; i++) printf("%d ", b[i]);
    puts("");
  }
  return 0;
}
