#include <bits/stdc++.h>
using namespace std;
int p[2200];
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) {
    int ans = i;
    map<int, int> mp;
    mp[ans]++;
    while (1) {
      mp[ans]++;
      ans = p[ans];
      if (mp[ans] == 2) break;
    }
    cout << ans << " ";
  }
  return 0;
}
