#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n + 1];
  arr[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= n; i++) {
    vector<int> hole(n + 1, 0);
    int j = i;
    while (true) {
      hole[j] += 1;
      if (hole[j] != 2) {
        j = arr[j];
      } else {
        cout << j << endl;
        break;
      }
    }
  }
  return 0;
}
