#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 10;
int a[1010], vis[1010];
int main() {
  int n, num;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
      memset(vis, 0, sizeof(vis));
      int temp = i;
      while (1) {
        vis[temp]++;
        if (vis[temp] == 2) {
          if (i != n)
            printf("%d ", temp);
          else
            printf("%d\n", temp);
          break;
        }
        temp = a[temp];
      }
    }
  }
  return 0;
}
