#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 4;
int n;
int a[N];
int ans[N];
int deg[N];
int print(int node) {
  if (node == ans[node]) return node;
  ans[node] = print(ans[node]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], deg[a[i]]++;
  for (int i = 1; i <= n; i++) ans[i] = i;
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (deg[i] == 0) q.push(i);
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    deg[a[x]]--;
    if (deg[a[x]] == 0) q.push(a[x]);
    ans[x] = a[x];
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] != i) print(i);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
