#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[10001], b[10001];
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    memset(b, 0, sizeof(b));
    int k = i;
    b[k]++;
    while (b[k] < 2) {
      k = a[k];
      b[k]++;
    }
    cout << k << ' ';
  }
  return 0;
}
