#include <bits/stdc++.h>
using namespace std;
long long n, ans;
string str;
long long solve() {
  cin >> n;
  long long v[1001];
  for (long long i = 0; i <= n - 1; ++i) {
    long long t;
    cin >> t;
    v[i + 1] = t;
  }
  for (long long i = 1; i <= n; ++i) {
    long long a[n + 1];
    for (long long i = 0; i <= n; ++i) a[i] = 0;
    a[i]++;
    long long t = i;
    while (1) {
      t = v[t];
      a[t]++;
      if (a[t] == 2) {
        cout << t << " ";
        break;
      }
    }
  }
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
