#include <bits/stdc++.h>
using namespace std;
long long a[10005];
bool used[10005];
int main() {
  int n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  int x;
  for (long long i = 1; i <= n; i++) {
    memset(used, 0, sizeof(used));
    x = i;
    while (!used[x]) {
      used[x] = 1;
      x = a[x];
    }
    cout << x << " ";
  }
  return 0;
}
