#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, ch = 0, x, j;
  cin >> n;
  int b[n + 1], a[n + 1];
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) b[j] = 0;
    b[i]++;
    x = i;
    while (ch == 0) {
      x = a[x];
      b[x]++;
      if (b[x] > 1) {
        cout << x << " ";
        ch = 1;
      }
    }
    ch = 0;
  }
  return 0;
}
