#include <bits/stdc++.h>
using namespace std;
bool b[1000] = {0};
int main() {
  int n;
  cin >> n;
  int a[n];
  int g = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    memset(b, 0, 1000);
    g = i;
    for (g; g < n; g = g) {
      if (b[g] == 1) {
        break;
      } else {
        b[g] = 1;
        g = a[g] - 1;
      }
    }
    cout << g + 1 << " ";
  }
  return 0;
}
