#include <bits/stdc++.h>
using namespace std;
int solve(int x, vector<int> &visited, vector<int> g[]) {
  if (visited[x]) return x;
  visited[x] = 1;
  return solve(g[x][0], visited, g);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<int> g[n + 1];
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    g[i].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    vector<int> visited(n + 1);
    cout << solve(i, visited, g) << " ";
  }
  cout << endl;
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
  return 0;
}
