#include <bits/stdc++.h>
using namespace std;
int n;
int p[1000];
bool vis[1000];
int solve(int v) {
  memset(vis, 0, sizeof(vis));
  while (!vis[v]) {
    vis[v] = true;
    v = p[v];
  }
  return v;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    cin >> p[i];
    --p[i];
  }
  for (int i = 0; i < (int)(n); i++) {
    cout << 1 + solve(i) << " ";
  }
  cout << endl;
  return 0;
}
