#include <bits/stdc++.h>
int a[1005], b[1005];
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    m = i;
    memset(b, 0, sizeof(b));
    b[i]++;
    while (b[m] < 2) {
      m = a[m];
      b[m]++;
    }
    printf("%d ", m);
  }
  return 0;
}
