#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int N = 1e6 + 5;
int p[1005];
bool vis[1005];
int dfs(int u) {
  if (vis[u]) return u;
  vis[u] = true;
  return dfs(p[u]);
}
int main() {
  int n, i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (i = 1; i <= n; i++) {
    memset(vis, false, sizeof(vis));
    cout << dfs(i) << " ";
  }
  return 0;
}
