#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int N = 1e3;
vector<int> mark(N + 1, 0);
vector<int> v(N + 1);
int c;
void dfs(int idx) {
  if (mark[idx] == 2) {
    c = idx;
    return;
  }
  mark[idx]++;
  dfs(v[idx]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc, ca = 0;
  int n, el;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    dfs(i);
    ans.push_back(c);
    for (int i = 1; i <= n; i++) {
      mark[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i];
    if (i != n - 1) cout << ' ';
  }
  cout << '\n';
  return 0;
}
