#include <bits/stdc++.h>
using namespace std;
long long a[1002], vis[1002], ans = 0;
vector<long long> adj[1002];
void dfs(long long v) {
  if (vis[v] == 1) {
    ans = v;
    return;
  }
  if (vis[v] == 0) {
    vis[v] = 1;
    dfs(adj[v][0]);
    vis[v] = 0;
    return;
  }
}
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    adj[i].push_back(a[i]);
  }
  for (long long i = 1; i <= n; i++) {
    ans = 0;
    dfs(i);
    cout << ans << ' ';
  }
  return 0;
}
