#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[1010], n;
  map<int, int> s;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    int t = i;
    while (true) {
      s[t]++;
      if (s[t] == 2) {
        i == n ? printf("%d\n", t) : printf("%d ", t);
        s.clear();
        break;
      }
      t = a[t];
    }
  }
  return 0;
}
