#include <bits/stdc++.h>
using namespace std;
const int OO = INT_MAX;
const int _OO = INT_MIN;
const double EPS = (1e-9);
const double pi = 3.14159265;
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy8[8] = {1, -1, 0, 1, -1, 1, -1, 0};
const int N = 1005;
vector<vector<int>> g(N);
bool vis[N];
int BFS(int node) {
  int v;
  memset(vis, 0, sizeof(vis));
  queue<int> q;
  vis[node] = 1;
  q.push(node);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 1;
    for (int i = 0; i < g[u].size(); i++) {
      v = g[u][i];
      if (!vis[v]) {
        vis[v] = 1;
        q.push(v);
      }
    }
  }
  return v;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    g[i].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    cout << BFS(i) << " ";
  }
  return 0;
}
