#include <bits/stdc++.h>
using namespace std;
int arr[1005];
int vis[1005];
void dfs(int x) {
  if (vis[x]) {
    cout << x << " ";
    return;
  } else {
    vis[x] = 1;
    dfs(arr[x]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    fill(vis, vis + 1005, 0);
    dfs(i);
  }
  return 0;
}
