#include <bits/stdc++.h>
using namespace std;
int stu[10001];
int main() {
  int n;
  cin >> n;
  int p[10001];
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; i++) {
    memset(stu, 0, sizeof(stu));
    int curr = i;
    for (int j = 1; j <= n + 1; j++) {
      stu[curr]++;
      if (stu[curr] >= 2) {
        cout << curr << ' ';
        break;
      } else
        curr = p[curr];
    }
  }
  cout << endl;
  return 0;
}
