#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *order = (int *)malloc(sizeof(int) * (n + 1));
  int *student = (int *)malloc(sizeof(int) * (n + 1));
  for (int i = 1; i <= n; i++) {
    cin >> order[i];
  }
  for (int i = 1; i <= n; i++) {
    memset(student, 0, sizeof(int) * (n + 1));
    int j = i;
    while (student[j] != 2) {
      student[j]++;
      j = order[j];
    }
    cout << j << " ";
  }
  return 0;
}
