#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n + 1];
  bool visited[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    memset(visited, false, n + 1);
    int x = i;
    visited[x] = true;
    for (int j = 0; j < n; j++) {
      if (visited[a[x]]) {
        cout << a[x] << " ";
        break;
      }
      visited[a[x]] = true;
      x = a[x];
    }
  }
}
