#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
long long power(long long b, long long e, long long m) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
long long modinv(long long a, long long m) { return power(a, m - 2, m); }
vector<bool> visited;
vector<long long int> ans;
vector<vector<long long int>> adj;
queue<long long int> q;
long long int n;
void bfs(long long int x) {
  visited[x] = true;
  q.push(x);
  while (!q.empty()) {
    x = q.front();
    q.pop();
    for (long long int i = 0; i < adj[x].size(); i++) {
      if (!visited[adj[x][i]]) {
        visited[adj[x][i]] = true;
        q.push(adj[x][i]);
      } else {
        ans.push_back(adj[x][i]);
        return;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  for (long long int g = 0; g < t; g++) {
    cin >> n;
    long long int a[n + 1];
    adj.resize(n + 1);
    visited.resize(n + 1);
    for (long long int i = 1; i <= n; i++) {
      cin >> a[i];
      adj[i].push_back(a[i]);
    }
    for (long long int i = 1; i <= n; i++) {
      bfs(i);
      for (long long int i = 0; i < visited.size(); i++) visited[i] = false;
      while (!q.empty()) q.pop();
    }
    for (long long int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  }
  return 0;
}
