#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  int parent[n + 1], ans[n + 1], tp;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    parent[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    if (parent[i] == -1) {
      tp = i;
      vector<int> cycle;
      while (parent[tp] != 1) {
        parent[tp] = 1;
        cycle.push_back(tp);
        tp = a[tp];
      }
      int j, f = 0;
      for (j = 0; j < cycle.size(); j++) {
        if (cycle[j] == tp) {
          f = 1;
        }
        if (f == 0) {
          ans[cycle[j]] = tp;
          parent[cycle[j]] = -1;
        } else {
          ans[cycle[j]] = cycle[j];
          parent[cycle[j]] = -1;
        }
      }
      cycle.clear();
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
