#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const double eps = 1e-9;
const int maxn = (int)1e6 + 10;
int a[maxn];
int b[maxn];
int mem[maxn];
int used[maxn];
int total = 0;
void make(vector<int> v) {
  total += ((int)(v).size());
  int step = (((int)(v).size()) + 1) / 2;
  for (int i = 0; (i) < (((int)(v).size())); ++i) {
    int j = (i + step) % ((int)(v).size());
    b[v[i]] = v[j];
  }
}
void make(vector<int> v1, vector<int> v2) {
  int n = ((int)(v1).size());
  total += 2 * n;
  v1.push_back(v1[0]);
  for (int i = 0; (i) < (n); ++i) {
    b[v1[i]] = v2[i];
    b[v2[i]] = v1[i + 1];
  }
}
vector<vector<int> > v;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; (i) < (n); ++i) scanf("%d", a + i);
  for (int i = 0; (i) < (n); ++i) --a[i];
  memset(mem, -1, sizeof mem);
  for (int i = 0; (i) < (n); ++i)
    if (!used[i]) {
      int x = i;
      vector<int> vv;
      while (!used[x]) {
        used[x] = 1;
        vv.push_back(x);
        x = a[x];
      }
      v.push_back(vv);
      if (((int)(vv).size()) & 1) {
        make(vv);
      } else {
        if (mem[((int)(vv).size())] == -1) {
          mem[((int)(vv).size())] = ((int)(v).size()) - 1;
        } else {
          make(vv, v[mem[((int)(vv).size())]]);
          mem[((int)(vv).size())] = -1;
        }
      }
    }
  if (total != n)
    printf("-1\n");
  else {
    for (int i = 0; (i) < (n); ++i) printf("%d%c", b[i] + 1, " \n"[i + 1 == n]);
    for (int i = 0; (i) < (n); ++i) assert(a[i] == b[b[i]]);
  }
  return 0;
}
