#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a[1011];
int ok[1011];
int d[1011];
void readData() {
  int p;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p;
    a[i].push_back(p);
  }
}
int bfs(int s) {
  int v;
  queue<int> qu;
  for (int i = 0; i <= n + 5; i++) {
    ok[i] = 0;
  }
  qu.push(s);
  ok[s] = 1;
  while (qu.size()) {
    int u = qu.front();
    qu.pop();
    for (int i = 0; i < a[u].size(); i++) {
      v = a[u][i];
      if (ok[v] == 0) {
        ok[v] = 1;
        qu.push(v);
      }
    }
  }
  return v;
}
int main() {
  readData();
  for (int i = 1; i <= n; i++) {
    cout << bfs(i);
    if (i == n) {
      cout << endl;
    } else
      cout << " ";
  }
}
