#include <bits/stdc++.h>
using namespace std;
int n, ar[1010];
bool b[1010];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> ar[i];
  }
  for (int i = 1; i <= n; ++i) {
    int yk = i;
    while (1) {
      if (b[yk]) break;
      b[yk] = 1;
      yk = ar[yk];
    }
    cout << yk << " ";
    fill(b, b + 1010, 0);
  }
  return 0;
}
