#include <bits/stdc++.h>
using namespace std;
int n;
int solve(int v, vector<int> &a) {
  vector<bool> used(n + 1, false);
  while (!used[v]) {
    used[v] = true;
    v = a[v];
  }
  return v;
}
int main() {
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    cout << solve(i, a) << " ";
  }
}
