#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
int arr[1001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m, T, res;
  int maxi = -(1 << 30) - 1, mini = (1 << 30) - 1, count = 0;
  int i, j, k;
  bool flag;
  string s1, s2;
  char s[100000];
  int ara[100005], ara2[100005];
  cin >> n;
  for (int i = (int)(1); i <= (int)(n); i++) cin >> ara[i], arr[ara[i]]++;
  vector<int> v;
  for (int i = (int)(1); i <= (int)(n); i++) {
    memset((arr), 0, sizeof(arr));
    arr[i]++;
    k = ara[i];
    while (true) {
      if (arr[k] == 1) {
        v.push_back(k);
        break;
      }
      arr[k]++;
      k = ara[k];
    }
  }
  for (int i = (int)(0); i <= (int)(v.size() - 1); i++) cout << v[i] << " ";
  cout << endl;
}
