#include <bits/stdc++.h>
using namespace std;
vector<int> v(1005);
bitset<2000> visited;
void dfs(int i) {
  if (visited[i]) {
    cout << i + 1;
    return;
  }
  visited[i] = true;
  dfs(v[i]);
}
int main() {
  int n, tes;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tes;
    v[i] = tes - 1;
  }
  for (int i = 0; i < n; i++) {
    visited.reset();
    dfs(i);
    cout << (i == n - 1 ? "\n" : " ");
  }
  return 0;
}
