#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n, i, j, k;
    cin >> n;
    int a[n + 1];
    for (i = 1; i <= n; i++) cin >> a[i];
    stack<int> s;
    int ans[n + 1];
    for (i = 1; i <= n; i++) {
      bool g[n + 1];
      memset(g, 0, sizeof(g));
      s.push(i);
      g[i] = 1;
      k = a[i];
      while (g[k] == 0) {
        s.push(k);
        g[k] = 1;
        k = a[k];
      }
      ans[i] = k;
    }
    for (i = 1; i <= n; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
