#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p[1234];
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  int vis[1001];
  for (int i = 0; i < n; i++) {
    int x = i + 1;
    memset(vis, 0, sizeof vis);
    while (1) {
      vis[x]++;
      if (vis[x] == 2) {
        cout << x << " ";
        break;
      }
      x = p[x];
    }
  }
  return 0;
}
