#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n + 1];
  vector<bool> vis;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long x = 1; x <= n; x++) {
    vis.clear();
    vis.assign(n + 1, false);
    long long i = x;
    while (!vis[i]) {
      vis[i] = true;
      i = a[i];
    }
    cout << i << " ";
  }
}
