#include <bits/stdc++.h>
using namespace std;
int a[1000], visited[1000];
int dfs(int i) {
  if (visited[i - 1] != 0) return i;
  visited[i - 1] = 1;
  int z = dfs(a[i - 1]);
  visited[i - 1] = 0;
  return z;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << dfs(i + 1) << " ";
  }
  return 0;
}
