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