#include <bits/stdc++.h>
using namespace std;
int n, m, k, t, vis[2222];
vector<int> v[2222];
void dfs(int s) {
  if (t != 1) return;
  vis[s] = 1;
  for (auto it : v[s]) {
    if (vis[it]) {
      t = it;
      return;
    }
    dfs(it);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    v[i].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    t = 1;
    for (int j = 1; j <= n; j++) vis[j] = 0;
    dfs(i);
    cout << t << ' ';
  }
}
