#include <bits/stdc++.h>
using namespace std;
vector<long long> blame(1002, 0);
vector<bool> visited(1002, false);
long long dfs(long long u) {
  if (visited[u]) return u;
  visited[u] = true;
  return dfs(blame[u]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> blame[i];
  }
  for (long long i = 1; i <= n; i++) {
    cout << dfs(i) << " ";
    fill(visited.begin(), visited.end(), false);
  }
  return 0;
}
