#include <bits/stdc++.h>
using namespace std;
int main() {
  int T = 1;
  while (T--) {
    long long int N, M, i, j = 0, k, x, y, z, inp, flag = 1, sum = 0, count = 0,
                           max = 0, r = 0, a, b, c;
    cin >> N;
    int arr[N + 1];
    for (i = 1; i < N + 1; i++) cin >> arr[i];
    for (i = 1; i < N + 1; i++) {
      y = i;
      map<int, int> m;
      while (m[y] < 2) {
        m[y]++;
        x = arr[y];
        y = x;
      }
      cout << y << " ";
    }
  }
  return 0;
}
