#include <bits/stdc++.h>
using namespace std;
vector<int> res;
vector<int> adj[100005];
bool visited[100005];
void dfs(int node);
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    adj[i].push_back(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    memset(visited, false, sizeof(visited));
    dfs(i);
  }
  for (int i = 0; i < res.size(); i++) cout << res[i] << ' ';
  cout << '\n';
}
void dfs(int node) {
  int v;
  if (visited[node] == true) return;
  visited[node] = true;
  for (int i = 0; i < (int)adj[node].size(); i++) {
    v = adj[node][i];
    if (visited[v] == true) res.push_back(v);
    dfs(v);
  }
}
