#include <bits/stdc++.h>
using namespace std;
int n;
int p[100001];
int colore[100001];
bool colorazioneBFSok(int v) {
  colore[v] = 1;
  colore[p[v]] = 2;
  int tmp = p[v];
  while (tmp != v) {
    if (colore[p[tmp]] == colore[tmp]) return false;
    colore[p[tmp]] = 3 - colore[tmp];
    tmp = p[tmp];
  }
  return true;
}
bool colora() {
  for (int i = 1; i <= n; i++)
    if (colore[i] == 0 && !colorazioneBFSok(i)) return false;
  return true;
}
void stampaSol(int a, int b) {
  printf("YES\n%d %d\n", a, b);
  for (int i = 1; i <= n; i++) {
    if (colore[i] == colore[a] && a != i) printf("%d %d\n", a, i);
    if (colore[i] == colore[b] && b != i) printf("%d %d\n", b, i);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", p + i);
  for (int i = 1; i <= n; i++) {
    if (p[i] == i) {
      printf("YES\n");
      for (int j = 1; j <= n; j++)
        if (i != j) {
          printf("%d %d\n", i, j);
        }
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) colore[i] = 0;
  if (colora()) {
    for (int i = 1; i <= n; i++) {
      if (i == p[p[i]]) {
        stampaSol(i, p[i]);
        return 0;
      }
    }
  }
  printf("NO");
  return 0;
}
