#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const long long inf = 1e18;
int main() {
  long long n;
  cin >> n;
  vector<long long> p(n);
  for (long long i = 0; i < n; i++) {
    cin >> p[i];
    p[i] -= 1;
  }
  for (long long i = 0; i < n; i++) {
    vector<bool> used(n, false);
    used[i] = true;
    for (long long j = p[i];; j = p[j])
      if (!used[j])
        used[j] = true;
      else {
        cout << j + 1 << ' ';
        break;
      }
  }
  return 0;
}
