#include <bits/stdc++.h>
using namespace std;
const long long PI = 3.1415926535897932384626433832795;
const long long INF = 8000000000000000000;
const long long mod = 1000000007;
const long long MOD = 1000000007;
const long long dx[] = {1, -1, 0, 0};
const long long dy[] = {0, 0, 1, -1};
const long long month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long n, p[1005];
bool visited[1005];
void dfs(long long d) {
  if (visited[d]) {
    cout << d << " ";
    return;
  }
  visited[d] = 1;
  dfs(p[d]);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> p[i];
  for (long long i = 1; i <= n; i++) {
    memset(visited, 0, sizeof visited);
    dfs(i);
  }
  exit(0);
}
