#include <bits/stdc++.h>
#pragma GCC optimize(3, "inline", "Ofast")
using namespace std;
int p[1010];
bool vis[1010];
void dfs(int pos) {
  if (vis[pos])
    return (void)(printf("%d ", pos));
  else
    vis[pos] = 1, dfs(p[pos]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) memset(vis, 0, sizeof vis), dfs(i);
}
