#include <bits/stdc++.h>
using namespace std;
void checkTime() { printf("\n%f seconds", (double)(clock()) / CLOCKS_PER_SEC); }
const double PI = 3.1415926535897932384626433832795;
const int mod = 1e9 + 7;
const int inf = 5e8 + 100;
const int N = 5e4 + 10;
const int M = 1e5 + 10;
int n;
int p[1010];
int ans[1010];
bool vis[1010];
int dfs(int v) {
  vis[v] = true;
  if (vis[p[v]]) return p[v];
  return dfs(p[v]);
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) {
    fill(vis, vis + n + 1, false);
    ans[i] = dfs(i);
    cout << ans[i] << ' ';
  }
  return;
}
int main() {
  int TE = 1;
  while (TE--) solve();
  return 0;
}
