#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n;
  int p[n + 10], m[n + 10];
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) {
    memset(m, 0, sizeof(m));
    a = i;
    m[i] = 1;
    while (1) {
      a = p[a];
      m[a]++;
      if (m[a] == 2) {
        cout << a << endl;
        break;
      }
    }
  }
  return 0;
}
