#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int k = 1; k <= n; k++) {
    set<int> s;
    s.insert(k);
    int x = a[k - 1];
    while (s.find(x) == s.end()) {
      s.insert(x);
      x = a[x - 1];
    }
    cout << x << " ";
  }
}
