#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T x, T y) {
  if (!y) return x;
  return gcd(y, x % y);
}
const int MOD = 1e9 + 7;
const int INF = 1e9;
vector<vector<int> > adj(1001);
bool visited[1001];
void dfs(int i, int& k) {
  if (visited[i]) {
    k = i;
    return;
  }
  visited[i] = true;
  for (auto it : adj[i]) dfs(it, k);
}
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    adj[i].push_back(x);
  }
  int k;
  for (int i = 1; i <= n; ++i) {
    memset(visited, false, sizeof(visited));
    k = i;
    dfs(i, k);
    cout << k << ' ';
  }
  return 0;
}
