#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, nxt[1010];
  bool vis[1010];
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> nxt[i];
  }
  for (int i = 1; i <= n; ++i) {
    memset(vis, false, sizeof(vis));
    int s = i;
    while (!vis[s]) {
      vis[s] = true;
      s = nxt[s];
    }
    if (i > 1) cout << ' ';
    cout << s;
  }
  cout << endl;
  return 0;
}
