#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-6;
vector<vector<int> > Q[1000005];
int shu[1000005];
int vis[1000005];
int n;
int main() {
  while (cin >> n) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &shu[i]);
    }
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++) {
      if (!vis[i]) {
        vector<int> q;
        int st = i;
        while (!vis[st]) {
          q.push_back(st);
          vis[st] = 1;
          st = shu[st];
        }
        Q[q.size()].push_back(q);
      }
    }
    for (int i = 1; i <= n; i++) {
      if (i % 2 == 1) {
        int jump = (i + 1) / 2;
        for (int j = 0; j < Q[i].size(); j++) {
          for (int k = 0; k < i; k++) {
            shu[Q[i][j][k]] = Q[i][j][(k + jump) % i];
          }
        }
      } else {
        if (Q[i].size() % 2) {
          cout << "-1" << endl;
          return 0;
        } else {
          for (int j = 0; j < Q[i].size(); j += 2) {
            for (int l = 0; l < i; l++) {
              shu[Q[i][j][l]] = Q[i][j + 1][l];
              shu[Q[i][j + 1][l]] = Q[i][j][(l + 1) % i];
            }
          }
        }
      }
    }
    for (int i = 1; i <= n; i++) printf("%d ", shu[i]);
    cout << endl;
  }
  return 0;
}
