#include <bits/stdc++.h>
using namespace std;
int a[1005], vis[1005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    int pos = i;
    while (vis[pos] < 2) {
      vis[pos]++;
      pos = a[pos];
    }
    cout << pos << " ";
    for (int j = 1; j <= n; j++) {
      vis[j] = 0;
    }
  }
}
