#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
bool f(long long x, long long y) { return x > y; }
vector<long long> graph[1000001];
long long vis[1000001];
long long level[100001];
long long dis[1000001];
long long countDivisors(long long n) {
  long long cnt = 0;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}
bool isPrime(long long n) {
  long long i;
  for (i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
void bfs(long long a) {
  queue<long long> q;
  q.push(a);
  vis[a] = 1;
  dis[a] = 0;
  while (!q.empty()) {
    long long curr = q.front();
    q.pop();
    for (auto &it : graph[curr]) {
      if (vis[it] == 0) {
        q.push(it);
        dis[it] = dis[curr] + 1;
        level[dis[it]]++;
        vis[it] = 1;
      }
    }
  }
}
int32_t main() {
  c_p_c();
  long long n;
  cin >> n;
  long long a[10001];
  long long i;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    map<long long, long long> ma;
    long long ind = i;
    while (1) {
      if (ma.find(ind) != ma.end()) {
        cout << ind << " ";
        break;
      } else
        ma[ind] = 1, ind = a[ind];
    }
  }
}
