#include <bits/stdc++.h>
using namespace std;
using namespace std;
const double pi = acos(-1);
const long long mod = 1e9 + 7;
const int N = 100005;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int a[1005];
int b[1005];
int f[1005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int p = 0;
  for (int i = 1; i <= n; i++) {
    memset(f, 0, sizeof(f));
    f[i] = 1;
    int pos = a[i];
    while (1) {
      f[pos]++;
      if (f[pos] >= 2) {
        b[p++] = pos;
        break;
      }
      pos = a[pos];
    }
  }
  for (int i = 0; i < n - 1; i++) {
    cout << b[i] << ' ';
  }
  cout << b[n - 1] << endl;
  return 0;
}
