#include <bits/stdc++.h>
using namespace std;
const int N = 110005;
int a[N], vis[N], st[2];
int n;
int work() {
  int flag = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    if (a[i] == i) {
      flag = i;
    }
  }
  if (flag != -1) {
    puts("YES");
    for (int i = 1; i <= n; i++) {
      if (i != flag) {
        printf("%d %d\n", flag, i);
      }
    }
    return 0;
  }
  flag = 0;
  int st1, st2;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      int k = 0, j = i, v = a[i];
      while (!vis[j]) {
        k++;
        vis[j] = 1;
        v = j;
        j = a[v];
      }
      if (k & 1) {
        puts("NO");
        return 0;
      }
      if (k == 2) {
        flag = 1;
        st[0] = i, st[1] = v;
      }
    }
  }
  if (!flag) {
    puts("NO");
    return 0;
  }
  memset(vis, 0, sizeof(vis));
  int temp;
  puts("YES");
  printf("%d %d\n", st[0], st[1]);
  vis[st[1]] = vis[st[0]] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) {
      int u = i;
      vis[i] = 1;
      int v = a[i];
      temp = 0;
      printf("%d %d\n", u, st[0]);
      while (v != i) {
        vis[v] = 1;
        temp ^= 1;
        printf("%d %d\n", v, st[temp]);
        v = a[v];
      }
    }
  }
}
int main() {
  while (~scanf("%d", &n)) {
    work();
  }
  return 0;
}
