#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
void solve() {
  int n, i, a[3000], b[3000];
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int i = 1; i <= n; i++) b[i] = 0;
    int x = i;
    while (b[x] != 2) {
      b[x]++;
      x = a[x];
    }
    cout << x << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
