#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int MAXN = 10000 + 5;
int p[1010];
bool vis[1010];
int dfs(int rt) {
  vis[rt] = true;
  if (vis[p[rt]]) return p[rt];
  return dfs(p[rt]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) {
    memset(vis, false, sizeof(vis));
    if (i > 1) printf(" ");
    printf("%d", dfs(i));
  }
  puts("");
  return 0;
}
