#include <bits/stdc++.h>
using namespace std;
signed main() {
  int count;
  cin >> count;
  int p[count];
  for (int i = 0; i < count; ++i) {
    cin >> p[i];
    --p[i];
  }
  vector<int> cycles[count + 1];
  vector<int> paths[count];
  int representative[count];
  int arr[count];
  for (int i = 0; i < count; ++i) {
    representative[i] = -1;
    arr[i] = i;
  }
  for (int i = 0; i < count; ++i) {
    if (representative[i] != -1) continue;
    representative[i] = i;
    int to = p[i];
    int sz = 1;
    vector<int> path;
    path.push_back(i);
    while (to != i) {
      representative[to] = i;
      sz++;
      path.push_back(to);
      to = p[to];
    }
    cycles[sz].push_back(i);
    paths[i] = path;
  }
  bool possible = true;
  for (int i = 2; i <= count; i += 2) {
    if (cycles[i].size() % 2) possible = false;
  }
  if (!possible) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= count; ++i) {
    if (i % 2) {
      for (int j = 0; j < cycles[i].size(); ++j) {
        vector<int> path = paths[cycles[i][j]];
        int terminal = (i - 1) / 2;
        arr[path[terminal]] = path[0];
        for (int k = 0; k < terminal; ++k) {
          arr[path[k]] = path[terminal + 1 + k];
          arr[path[terminal + 1 + k]] = path[k + 1];
        }
      }
    } else {
      for (int j = 0; j < cycles[i].size(); j += 2) {
        vector<int> path_a = paths[cycles[i][j]];
        vector<int> path_b = paths[cycles[i][j + 1]];
        for (int k = 0; k < i; k++) {
          arr[path_a[k]] = path_b[k];
          arr[path_b[k]] = path_a[(k + 1) % i];
        }
      }
    }
  }
  for (int i = 0; i < count; ++i) {
    cout << arr[i] + 1 << " ";
  }
  cout << endl;
  return 0;
}
