#include <bits/stdc++.h>
using namespace std;
int par[200020];
int vis[200020];
int find_root(int s) {
  vis[s] = 1;
  if (vis[par[s]]) return par[s];
  find_root(par[s]);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &par[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      vis[j] = 0;
    }
    printf("%d ", find_root(i));
  }
  return 0;
}
