#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, bool>> vec(n);
  for (int i = 0; i < n; ++i) {
    cin >> vec[i].first;
    vec[i].second = 0;
  }
  for (int i = 0; i < n; ++i) {
    int j = i;
    while (true) {
      if (vec[j].second == false) {
        vec[j].second = true;
        j = vec[j].first - 1;
      } else {
        cout << j + 1 << " ";
        break;
      }
    }
    for (int k = 0; k < n; ++k) {
      vec[k].second = false;
    }
  }
}
