#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; i++) {
    set<int> s;
    s.insert(i);
    int j = i;
    while (1) {
      if (s.find(p[j]) == s.end()) {
        s.insert(p[j]);
        j = p[j];
      } else {
        cout << p[j] << " ";
        break;
      }
    }
  }
  cout << endl;
  return 0;
}
