#include <bits/stdc++.h>
using namespace std;
vector<int> graph[1005];
int dfs(int ele, int visited[]) {
  visited[ele] = 1;
  for (auto v : graph[ele]) {
    if (visited[v] != 1) {
      int x = dfs(v, visited);
      if (x != -1) return x;
    } else
      return v + 1;
  }
  return -1;
}
int main() {
  int n, v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v;
    graph[i].push_back(v - 1);
  }
  for (int i = 0; i < n; i++) {
    int visited[1005] = {0};
    cout << dfs(i, visited) << " ";
  }
}
