#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int s[N], ret[N], a[N], b[N];
int main() {
  int cur = 0, n, i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (i = 1; i <= n; ++i) {
    if (b[a[i]]) continue;
    cur = 0;
    for (j = a[i]; !b[a[j]]; j = a[j]) ++cur, b[a[j]] = 1;
    if (cur & 1) {
      int x = a[i], u = a[i];
      for (j = 0; j < (cur) / 2; ++j) x = a[x];
      ret[i] = x;
      for (j = 0; j < cur - 1; ++j) {
        ret[u] = a[x];
        x = a[x];
        u = a[u];
      }
    } else {
      int t = s[cur];
      if (t == 0) {
        s[cur] = i;
        continue;
      }
      s[cur] = 0;
      int u = i;
      for (j = 0; j < cur; ++j) {
        ret[t] = u, ret[u] = a[t];
        t = a[t], u = a[u];
      }
    }
  }
  for (i = 0; i <= n; i += 2)
    if (s[i]) {
      printf("-1\n");
      return 0;
    }
  for (i = 1; i <= n; ++i) printf("%d ", ret[i]);
  cout << endl;
}
