#include <bits/stdc++.h>
using namespace std;
int A[2][1000] = {};
int DFS(int v) {
  A[1][v] = 1;
  if (A[1][A[0][v]]) return A[0][v];
  return DFS(A[0][v]);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    A[0][i] = t - 1;
  }
  for (int i = 0; i < n; i++) {
    cout << DFS(i) + 1 << " ";
    for (int j = 0; j < n; j++) {
      A[1][j] = 0;
    }
  }
}
