#include <bits/stdc++.h>
using namespace std;
int A[1000010], B[1000010], visited[1000010], ans[1000010];
vector<int> cur;
vector<vector<int> > cycles[1000010];
void findcycle(int s) {
  visited[s] = 1;
  cur.push_back(s);
  if (!visited[A[s]]) findcycle(A[s]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      findcycle(i);
      cycles[cur.size()].push_back(cur);
      cur.clear();
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 0 && cycles[i].size() % 2) {
      cout << -1 << '\n';
      return 0;
    }
    if (i % 2) {
      for (int j = 0; j < cycles[i].size(); j++) {
        vector<int> temp = cycles[i][j];
        for (int k = 0; k < temp.size(); k++) {
          ans[temp[k]] = temp[(k + (i + 1) / 2) % temp.size()];
        }
      }
    } else {
      for (int j = 0; j < cycles[i].size(); j += 2) {
        vector<int> temp1 = cycles[i][j];
        vector<int> temp2 = cycles[i][j + 1];
        int ptr1 = 0, ptr2 = 0;
        vector<int> cur;
        for (int k = 0; k < temp1.size() + temp2.size(); k++) {
          if (k % 2 == 0) {
            cur.push_back(temp1[ptr1++]);
          } else {
            cur.push_back(temp2[ptr2++]);
          }
        }
        int x = cur.size();
        for (int k = 0; k < cur.size(); k++) {
          ans[cur[k]] = cur[(k + 1) % cur.size()];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << '\n';
}
