#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int child[n + 1];
  map<int, bool> m;
  for (int i = 1; i <= n; i++) cin >> child[i];
  for (int i = 1; i <= n; i++) {
    m.clear();
    m[i] = true;
    int j = child[i];
    while (!m[j]) {
      m[j] = true;
      j = child[j];
    }
    cout << j << " ";
  }
  return 0;
}
