#include <bits/stdc++.h>
using namespace std;
int arr[200001];
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i]--;
  }
  for (int i = 0; i < n; i++) {
    vector<int> v(n, 0);
    int j = i;
    while (!v[j]) {
      v[j] = 1;
      j = arr[j];
    }
    cout << j + 1 << endl;
  }
}
