#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int p[1005], vis[1005];
int main(void) {
  int n;
  while (~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);
      int nt = i;
      while (!vis[nt]) {
        vis[nt] = 1;
        nt = p[nt];
      }
      printf("%d%c", nt, i == n ? '\n' : ' ');
    }
  }
  return 0;
}
