#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double eps = 1e-9;
const int N = 1e3 + 3;
int n, a[N], h[N];
int getP(int cr) {
  h[cr]++;
  if (h[cr] == 2) return cr;
  return getP(a[cr]);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int p;
    cin >> p;
    a[i] = p;
  }
  for (int i = 1; i < n + 1; i++) {
    memset(h, 0, sizeof h);
    cout << getP(i) << " ";
  }
  cout << endl;
  return 0;
}
