#include <bits/stdc++.h>
using namespace std;
vector<int> L[1007];
int n, viz[1007];
void Citire() {
  int x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    L[i].push_back(x);
  }
}
void DFS(int x) {
  int i, j;
  if (viz[x] == 1) {
    cout << x << " ";
    return;
  }
  viz[x]++;
  for (j = 0; j < L[x].size(); j++) {
    i = L[x][j];
    DFS(i);
  }
}
void Initializare() {
  for (int i = 1; i <= n; i++) viz[i] = 0;
}
void Rezolva() {
  for (int i = 1; i <= n; i++) {
    Initializare();
    DFS(i);
  }
}
int main() {
  Citire();
  Rezolva();
  return 0;
}
