#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int mark[1002] = {0}, next;
  for (int i = 1; i <= n; i++) {
    fill(mark, mark + 1002, 0);
    mark[i] = 1;
    next = arr[i];
    while (1) {
      if (mark[next]) {
        cout << next << " ";
        break;
      } else {
        mark[next] = 1;
        next = arr[next];
      }
    }
  }
}
