#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
const int mod = 1e9 + 7;
const double eps = 1e-9;
int p[maxn];
int vis[maxn];
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, 0, sizeof(vis));
    vis[i] = 1;
    int res = p[i];
    while (!vis[res]) {
      vis[res] = 1;
      res = p[res];
    }
    printf("%d ", res);
  }
  return 0;
}
