#include <bits/stdc++.h>
using namespace std;
int n;
int p[1001];
bool visited[1001];
int x;
void dfs(int i) {
  if (visited[i]) {
    x = i;
    return;
  }
  visited[i] = 1;
  dfs(p[i]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; i++) {
    x = 0;
    for (int i = 1; i <= n; i++) visited[i] = 0;
    dfs(i);
    cout << x << " ";
  }
  cout << "\n";
}
