#include <bits/stdc++.h>
const int maxn = 100000 + 10;
int a[maxn];
bool v[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == i) {
      printf("YES\n");
      for (int j = 1; j <= n; j++)
        if (j != i) printf("%d %d\n", j, i);
      return 0;
    }
  }
  memset(v, 0, sizeof(v));
  int cycle = -1;
  for (int i = 1; i <= n; i++) {
    int cnt = 0, pl = i;
    while (true) {
      if (v[pl]) break;
      v[pl] = true;
      cnt++;
      pl = a[pl];
    }
    if (cnt == 2) cycle = i;
    if (cnt & 1) {
      printf("NO\n");
      return 0;
    }
  }
  if (cycle == -1) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  printf("%d %d\n", cycle, a[cycle]);
  memset(v, 0, sizeof(v));
  for (int i = 1; i <= n; i++) {
    if (i == cycle || i == a[cycle]) continue;
    int pl = i, obs = cycle;
    while (true) {
      if (v[pl]) break;
      v[pl] = true;
      printf("%d %d\n", pl, obs);
      pl = a[pl];
      obs = a[obs];
    }
  }
  return 0;
}
