#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000 + 5;
int n, p[MAX_N], num[MAX_N], cl[MAX_N];
void dfs(int i, int x) {
  num[i]++;
  if (num[i] == 2) {
    cl[x] = i;
  } else {
    dfs(p[i], x);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) num[j] = 0;
    dfs(i, i);
    cout << cl[i] << " ";
  }
  return 0;
}
