#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long dfs(long long u, vector<long long> adj[], vector<bool>& vis) {
  vis[u] = true;
  for (long long v : adj[u]) {
    if (!vis[v])
      return dfs(v, adj, vis);
    else
      return v;
  }
  return -1;
}
void solve() {
  long long n;
  cin >> n;
  long long p[n];
  vector<long long> adj[n + 1];
  for (long long i = 0; i < n; i++) {
    cin >> p[i];
    adj[i + 1].push_back(p[i]);
  }
  for (long long i = 1; i <= n; i++) {
    vector<bool> vis(n + 1, false);
    cout << dfs(i, adj, vis) << " ";
  }
  cout << '\n';
}
signed main() {
  long long test = 1;
  while (test--) solve();
}
