#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  int b[1234];
  int a[1234];
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    memset(b, 0, sizeof(b));
    b[i] = 1;
    x = i;
    while (1) {
      x = a[x];
      b[x]++;
      if (b[x] > 1) break;
    }
    if (i == n)
      printf("%d\n", x);
    else
      printf("%d ", x);
  }
  return 0;
}
