#include <bits/stdc++.h>
using namespace std;
auto clk = clock();
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
const long long int mx = 100000;
int ans[1005] = {0};
int in_cycle[1005] = {0};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  int n;
  cin >> n;
  int a[1005];
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    unordered_map<int, bool> visited;
    int j = i;
    while (!visited[j]) {
      visited[j] = true;
      j = a[j];
    }
    cout << j << " ";
  }
}
