#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n + 8];
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    int freq[1005] = {}, idx = i;
    while (!freq[idx]++) idx = a[idx];
    printf("%d ", idx);
  }
}
