#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e9 + 7;
const double PI = acos(-1.0);
vector<int> arr(1005);
vector<bool> vb(1005);
int dfs(int a) {
  fill(vb.begin(), vb.end(), 0);
  int to = a;
  while (vb[to] == 0) {
    vb[to] = 1;
    to = arr[to];
  }
  return to;
}
void solve() {
  int n;
  cin >> n;
  for (int a = 0; a < n; a++) {
    cin >> arr[a];
    arr[a]--;
  }
  for (int a = 0; a < n; a++) cout << dfs(a) + 1 << ' ';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  return 0;
}
