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