#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, i, x, j;
  cin >> n;
  int p[n];
  for (i = 0; i < n; i++) {
    cin >> x;
    p[i] = x - 1;
  }
  int a[n];
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      a[j] = 0;
    }
    int cnt = 0;
    while (true) {
      if (cnt == 0) {
        j = i;
        a[j] = 1;
      }
      if (a[p[j]] == 1) {
        j = p[j];
        break;
      }
      a[p[j]] = 1;
      j = p[j];
      cnt++;
    }
    cout << j + 1 << " ";
  }
  return 0;
}
