#include <bits/stdc++.h>
using namespace std;
int n, id, nxt[100005], num[100005], mark[100005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &nxt[i]);
    if (nxt[i] == i) {
      puts("YES");
      for (int j = 1; j <= n; j++)
        if (j != i) printf("%d %d\n", i, j);
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (num[i]) continue;
    int j = nxt[i], t = 1;
    while (j != i) j = nxt[j], t++;
    while (!num[j]) num[j] = t, j = nxt[j];
    if (t & 1) {
      puts("NO");
      return 0;
    }
    if (t == 2) id = i;
  }
  if (!id) {
    puts("NO");
    return 0;
  }
  puts("YES");
  printf("%d %d\n", id, nxt[id]);
  for (int i = 1; i <= n; i++) {
    if (i == id || i == nxt[id] || mark[i]) continue;
    int a = id, b = i;
    while (num[i]--) {
      printf("%d %d\n", a, b);
      mark[b] = 1;
      a = nxt[a];
      b = nxt[b];
    }
  }
  return 0;
}
