#include <bits/stdc++.h>
const int MAXN = 1000 + 5;
int n;
int a[MAXN], c[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    memset(c, 0, sizeof(c));
    int now = i;
    while (c[now] != 2) {
      c[now]++;
      if (c[now] == 2) break;
      now = a[now];
    }
    printf("%d ", now);
  }
  return 0;
}
